This project has moved and is read-only. For the latest updates, please go here.

Hello Color

The ColoredConsoleTraceListener is a replacement for the standard ConsoleTraceListener that colorizes the output according to the TraceEventType. The listener also has allows trace details to be output according to a user-supplied template.

By default errors are output in red, warnings in yellow and information messages in white. The default template matches the format output by the standard ConsoleTraceListener.

Use the following config file, along with the Hello Logging sample program. You do not need to recompile the sample program.

This example requires you to download the Essential.Diagnostics extensions and add the DLL to the same directory as the example, however you do not need to recompile your program (just change the config file). For a real project however the simplest way to add Essential.Diagnostics is with Nuget via "nuget Essential.Diagnostics.Config".

<?xml version="1.0" encoding="utf-8" ?>
      <add name="color"
         type="Essential.Diagnostics.ColoredConsoleTraceListener, Essential.Diagnostics"
         format="{DateTime} {EventType}: {Message}"
         transferColor="Blue" />
      <source name="HelloProgram" switchValue="Information,ActivityTracing">
          <clear />
          <add name="color" />
      <source name="HelloWorker" switchValue="All">
          <clear />
          <add name="color" />

When you run the program, you should get output similar to the following.

Colored Console Example

Messages are colored and output according to the custom template.

Last edited Jun 5, 2013 at 1:46 PM by sgryphon, version 9


marnixvv Dec 21, 2011 at 8:25 AM 
For the current version (1.1.10711.0) replace format=... with template=... in HelloLogging.exe.config