Browse DevX
Sign up for e-mail newsletters from DevX


The Enterprise Instrumentation Framework : Page 4

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.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

A Custom Event Source
What we have now is a separate API for every event store. What we need is a common approach to instrumenting code while targeting all existing event stores (WMI, event log, text file, etc.) and all new event stores.
In the previous example, you may have noticed that the event source name was simply "Application." This is the implicit event source that gets used when calling the Raise method. However, if you want to filter and group related messages, you will want to explicitly define your event sources.

Thankfully, it is not difficult to create a custom event source with the EIF. You simply declare an EventSource type as in the following class-level declaration:

private static EventSource myEventSource = new EventSource("MyEventSource");

Next, to use this explicit event source, you simply call an overload of the Raise method that you used previously.

TraceMessageEvent.Raise(myEventSource, "MyMessage");

Figure 2 illustrates the results.

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