ColoredConsoleAppender ClassApache log4net™ SDK Documentation
Appends logging events to the console.
Inheritance Hierarchy

OnlineSystem Object
  log4net.Appender AppenderSkeleton
    log4net.Appender ColoredConsoleAppender

Namespace: log4net.Appender
Assembly: log4net (in log4net.dll) Version: 1.2.15.0 (1.2.15.0)
Syntax

public class ColoredConsoleAppender : AppenderSkeleton
Remarks

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.ErrorTextWriter. 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:

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

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

  • Blue
  • Green
  • Red
  • White
  • Yellow
  • Purple
  • Cyan
  • HighIntensity

See Also