In Enterprise Library for Microsoft (EntLib v3.1), you can use the WMI TraceListener (WMITraceListener class) to send logging events/statistics to the Windows Performance Monitor application.
Steps:
- Enable Instrumentation on the host: Start / All Programs / Microsoft Patterns & Practices / Enteprise Library 3.1 - May 2007 / Install Instrumentation
- With Enterprise Library Configuration, configure your app.config or web.config to use the WMI TraceListener.
- With Enterprise Library Configuration, add Instrumentation
- Edit the resulting config file (from previous steps) to set the instrumentation properties to "true": <instrumentationconfiguration performanceCountersEnabled="true"
eventLoggingEnabled="true" wmiEnabled="true" /> - If you have subclassed LogEntry, make sure any custom typed Attributes are decorated with [IgnoreMember] (you'll have to have System.Management as a Reference)
- Run your program
- Add a new Counter in Windows Performance Monitor: Performance Object "Enterprise Library Logging Counter"; Select counters from list; Select your program's instance.
- If "Enterprise Library Logging Counter" isn't available in Performance Monitor, then you didn't Install Instrumentation in EntLib.
- If you can't select an instance while adding the Counter, then your program probably isn't running, or something is preventing it from being instrumentable
- If the application event log contains errors suggesting that you use IgnoreMember, then you are logging a subclassed EventLog that has Attributes with special types (the event log error will say which one). Or change the type of you attributes to string, int, etc... to avoid the problem.
No comments:
Post a Comment