views:

28

answers:

1

I need to perform logging to console (or debug/trace). Currently I'm using Ent Lib 4.1 Logging Application Block. To log to console I use SystemDiagnosticsTraceListenerData and System.Diagnostics.ConsoleTraceListener.

It performs logging to console fine, but I'm not able to use formatter for this lister type and thus can't format log entries to desired format. What I need is just log message, without having all additional info tha is provided by default (which makes logs less readable for my case).

Is there any configuration option I'm missing to enable formatting for SystemDiagnosticsTraceListener?

A: 

I don't know if this helps (since you are using LAB), but Ukadc.Diagnostics is a set of System.Diagnostics extensions. One major addition (as compared to System.Diagnostics) is the addition of the ability to format the logging output, similar to what can be accomplished with Log4net, NLog, and LAB. You can even extend the formatting capability by writing your own "tokens". Tokens are objects called by the custom TraceListeners provided by Ukadc.Diagnostics to get the information to be logged (along with the log message itself). For example, I wrote an object to calculate the time delta in milliseconds since the start of the process. If I include the corresponding token in the format statement, each log message will include that delta.

See these links:

Ukadc.Diagnostics on codeplex

The developer's blog

wageoghe