About Text Formatters

Topics: Logging Application Block
Apr 27, 2009 at 9:39 AM

[Regarding: Logging Application Block]

I would like to be able to define different log levels say, Debug, Warning, Information, Error etc. The details written to the Log will be based upon the appropriate chioce I make. For E.g, If I choose Debug, Then I would like to Log all the available details, such as Timestamp, Process Id, etc. If the choice is Information, only a subset of the details needs to be logged.

I would like to know how to Use the Enterprise Library Configuration tool to configure my app.config for such a need. Please help.

Thank You,
Apr 27, 2009 at 11:30 AM

You can configure multiple categories with different "SourceLevels", or you can try to use the Filter property of a TraceListener. For displaying certain information based on the log level, you can play around with the "Template" property of the Formatter that is associated with the traceListener. 

Properties of the Logging Application Block: http://msdn.microsoft.com/en-us/library/dd203255.aspx
A tutorial for Logging Application Block - http://www.dotnetscraps.com/dotnetscraps/post/How-To-Configure-and-Use-the-Logging-Application-Block.aspx

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Apr 27, 2009 at 1:02 PM
Hi Valiant,

I tried the walkthrough mentioned on the link. Looks like, to achieve the above, I should have as many Text Formatters, Trace Listeners and Category Sources as the number of levels I need based on the amount of logging details for each level. If that is the case then I guess, my question is answered.

Thanks a ton for your help!!!

Apr 28, 2009 at 2:53 AM
Yes, that's what you need to do.  

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.