Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

The Enterprise Instrumentation Framework : Page 3

The Enterprise Instrumentation Framework (EIF) provides an easy-to-use and unified API for writing trace messages out to any and all event sinks including: the event log, WMI, text files, MSMQ, etc.


advertisement
The EIF in Action
To output messages to event sinks (listeners like the event log) with the EIF you simply call the static Raise method of the TraceMessageEvent class as follows:

TraceMessageEvent.Raise("MyMessage");

This one line API call makes good on the promise of a simple instrumentation API.

The next step is to generate (or create) a configuration file. This configuration file will allow you (or the administrator of your application) to turn on and off the output and capturing of trace messages in your application. Like all config files in .NET, this file is XML. Let's take a quick look at the details of the XML contained in this file:

Event Sources: Used to indicate the source (or provider) of the trace message (application is the intrinsic event source)

<eventSources> <eventSource name="Application" type="softwareElement" internalExceptionHandler="ignore" description="Application event source." /> </eventSources>

Event Sinks: These are the consumers of the trace messages (event log for example)


<eventSinks> <eventSink name="wmiSink" description="Outputs events to WMI." type="Microsoft.EnterpriseInstrumentation. EventSinks.WmiEventSink" /> <eventSink name="traceSink" description="Outputs events to the Windows Event Trace." type="Microsoft.EnterpriseInstrumentation. EventSinks.TraceEventSink"> <parameter name="sessionName" value="TraceSession" /> </eventSink> <eventSink name="logSink" description="Outputs events to the event log." type="Microsoft.EnterpriseInstrumentation. EventSinks.LogEventSink"> <parameter name="entryTypeFieldName" value="EventLogEntryTypeID" /> <parameter name="defaultEntryType" value="Information" /> <parameter name="machineName" value="." /> </eventSink> </eventSinks>

Event Categories: Used to group messages ("Errors" or "Broken Rules" for example)

<eventCategories> <eventCategory name="All Events" description="A category for all events."> <event type="System.Object" /> </eventCategory> <eventCategory> ... </eventCategory> </eventCategories>

Event Filters: Used to bind event categories to event sinks

<filters> <filter name="defaultSoftwareElementFilter" description="Software Element event sources."> <eventCategoryRef name="All Events"> <eventSinkRef name="wmiSink" /> <eventSinkRef name="traceSink" /> <eventSinkRef name="logSink" /> </eventCategoryRef> </filter> <filter name="defaultRequestFilter" description=" Request event sources."> <eventCategoryRef name="All Events"> <eventSinkRef name="wmiSink" /> <eventSinkRef name="traceSink" /> <eventSinkRef name="logSink" /> </eventCategoryRef> </filter> </filters>

Filter Bindings: Used to bind event sources to event filters

<filterBindings> <eventSourceRef name="Application"> <filterRef name="defaultSoftwareElementFilter" /> </eventSourceRef> </filterBindings>

This configuration file is generated and manipulated for us at design time by the EIF. You will undoubtedly want to modify this configuration file yourself and perhaps share a common configuration file across your application. In addition, you may want to leverage the configuration API provided by the EIF to expose the contents of this file to editing by the system administrators.

Now let's take a look at what our one line API call output to the event log. Figure 1 provides a graphical depiction of the trace message inside the event log.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date