Why is System Diagnostics Trace Listener not using formater?

Topics: Logging Application Block
Jul 2, 2011 at 11:35 AM


Can you please help me understanding how to customize the output of this type of listner (there is no way to customize text formatter)?

In detail

Right now in my code I have sprinkled on a lot of places calls to Debug.WriteLine(“….”).
The calls are omitted in release build and they fit nice with DbgView.,

The downside of this approach is also the fact that they are omitted in release build, because sometimes you want to turn on diagnostics for a short time to get info on production defects etc.

 That’s why I refactored my code and replaced all the Debug.WriteLine() calls with something like this


configure System Diagnostics Trace Listner to be used with System.Diagnostics.DefaultTraceListener, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

The result I got was the same: Output window and DbgView showing the data as old code did but in format I believe to match standard TextFormatter

Bootstrap Information: 1 : Timestamp: 7/2/2011 10:29:23 AM
Message: IOC ==> Registering in IoC component mapping of Framework.Prism.Services.IRegionOperations as #2 mapping
Category: Bootstrap
Priority: 0
EventId: 1
Severity: Information
Machine: NIVA-PC
App Domain: Atlas.Client.Shell.vshost.exe
ProcessId: 5420
Process Name: C:\build\debug\Atlas.Client.Shell.vshost.exe
Thread Name:
Win32 ThreadId:8180
Extended Properties:





What I need is to (the same I did before EntLib) output only the message text but (to my surprise) it looks like there is no way from Fluent API and configuration tool to set the text formatter to be used with System Diagnostics Trace Listner.


Jul 4, 2011 at 3:31 AM


You need to create a custom trace listener and format your message there, then use it as the Type Name of your System Diagnostics Trace Listener.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.