Logging App Block

Topics: Logging Application Block
Apr 13, 2007 at 4:38 PM
Hi. I plan to implement the LAB v2.0 for a web application my team is building. I'm trying to understand how it all works. With LAB v2.0 will I have to:

1. Create my own listener class(es) that implement InstrumentationListener?
2. Create my own provider class?
3. Write binder code that implements IExplicitInstrumentationBinder?

I've seen examples and snippets that don't seem to mention these details. I'm new to the Enterprise Library, so please forgive any nonsense questions. Thanks for the help.
Apr 13, 2007 at 5:34 PM
The classes you're referring to are all part of the instrumentation subsystem, which all of the blocks use to fire WMI events, performance counters and event log entries based on the configuration settings in the Instrumentation section. While you can extend the instrumentation system if you want, it's not a very common scenario. You definitely don't need to dive into this code to use the Logging Application Block - I'd suggest looking through the QuickStarts to see how to use the block and to implement your own TraceListener classes.

Tom
Apr 13, 2007 at 6:53 PM
tomhollander,

Thanks for the quick response. I will need to fire WMI events and use perfmon counters for my project. Does your response mean that I will have to "extend the instrumentation system" to do what I want? According to the example I found online by David Hayden ("http://codebetter.com/blogs/david.hayden/archive/2006/02/19/138644.aspx"), I can use the static factories and the Global.asax file to trap and handle my exceptions using the default TraceListeners. To create custom TraceListeners, would I do something like what is shown here?

http://www.eggheadcafe.com/articles/20041116.asp

Thanks again for the help.

Regards,

byronfromwes92


tomhollander wrote:
The classes you're referring to are all part of the instrumentation subsystem, which all of the blocks use to fire WMI events, performance counters and event log entries based on the configuration settings in the Instrumentation section. While you can extend the instrumentation system if you want, it's not a very common scenario. You definitely don't need to dive into this code to use the Logging Application Block - I'd suggest looking through the QuickStarts to see how to use the block and to implement your own TraceListener classes.

Tom

Apr 13, 2007 at 9:27 PM
You'll only need to extend the instrumentation code if the block doesn't fire events for the things you want. The Logging Application Block also lets you implement basic instrumentation in other ways: using the WmiTraceListener will fire WMI events for a log call, and the Tracer class will increment a number of performance counters (if instrumentation is switched on in configuration). So while I can't say for sure, I'd expect you should be able to meet your requirements without having to build new instrumentation listeners.

Regarding building your own Trace Listeners, the code you reference will work, however it won't take advantage of EntLib-specific features such as configuration and formatters. I'd suggest looking at the sample TraceListener included in the Logging QuickStart and using that as a guide.

Tom