Apache log4net� SDK Documentation - Microsoft .NET Framework 4.0

AnsiColorTerminalAppender Class

Appends logging events to the terminal using ANSI color escape sequences.

For a list of all members of this type, see AnsiColorTerminalAppender Members.

System.Object
���log4net.Appender.AppenderSkeleton
������log4net.Appender.AnsiColorTerminalAppender

[Visual�Basic]
Public�Class�AnsiColorTerminalAppender
����Inherits�AppenderSkeleton
[C#]
public�class�AnsiColorTerminalAppender : AppenderSkeleton

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

AnsiColorTerminalAppender appends log events to the standard output stream or the error output stream using a layout specified by the user. It also allows the color of a specific level of message to be set.

Note��� This appender expects the terminal to understand the VT100 control set in order to interpret the color codes. If the terminal or console does not understand the control codes the behavior is not defined.

By default, all output is written to the console's standard output stream. The Target property can be set to direct the output to the error stream.

NOTE: This appender writes each message to the System.Console.Out or System.Console.Error that is set at the time the event is appended. Therefore it is possible to programmatically redirect the output of this appender (for example NUnit does this to capture program output). While this is the desired behavior of this appender it may have security implications in your application.

When configuring the ANSI colored terminal appender, a mapping should be specified to map a logging level to a color. For example:

[XML]
<mapping>
    <level value="ERROR" />
    <foreColor value="White" />
    <backColor value="Red" />
    <attributes value="Bright,Underscore" />
</mapping>
<mapping>
    <level value="DEBUG" />
    <backColor value="Green" />
</mapping>

The Level is the standard log4net logging level and ForeColor and BackColor can be any of the following values:

These color values cannot be combined together to make new colors.

The attributes can be any combination of the following:

While any of these attributes may be combined together not all combinations work well together, for example setting both Bright and Dim attributes makes no sense.

Requirements

Namespace: log4net.Appender

Assembly: log4net (in log4net.dll)

See Also

AnsiColorTerminalAppender Members | log4net.Appender Namespace