Apache log4net� SDK Documentation - Microsoft .NET Framework 4.0

ColoredConsoleAppender Class

Appends logging events to the console.

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


public�class�ColoredConsoleAppender : 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.


ColoredConsoleAppender 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 type of message to be set.

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 directly to the application's attached console not to the System.Console.Out or System.Console.Error TextWriter. The System.Console.Out and System.Console.Error streams can be programmatically redirected (for example NUnit does this to capture program output). This appender will ignore these redirections because it needs to use Win32 API calls to colorize the output. To respect these redirections the ConsoleAppender must be used.

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

    <level value="ERROR" />
    <foreColor value="White" />
    <backColor value="Red, HighIntensity" />
    <level value="DEBUG" />
    <backColor value="Green" />

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


Namespace: log4net.Appender

Assembly: log4net (in log4net.dll)

See Also

ColoredConsoleAppender Members | log4net.Appender Namespace