One of the reasons I haven't been blogging lately is because I've been pretty busy with projects at work. One of the projects is a .Net application written in C#. I'm currently working on some of the logging functionality and I was inspired by the logging in FABRIQ. FABRIQ uses the Enterprise Instrumentation Framework to do its logging. At first I was overwhelmed by the amount of code FABRIQ used just to log an event, but I quickly saw the value in EIF once I started to play around with it.
One of the cool things about EIF is you can set what (where?) you log to at runtime (and change it while your app is running). The way EIF does this is to use Event Sinks. Out of the box, EIF comes with three of these events sinks: WMI, trace, and log. The trace event sink writes an event trace to the EIF trace log. The log event sink writes the event to the event log. You specify which types of events you want to write to which type of event sink in the EnterpriseInstrumentation.config file.
Ok, so now you know a little about EIF. Now in my case I wanted to be able to output trace information to my old friend DebugView. I didn't see an easy way to do this with EIF (although there might be one) so I wrote a custom event sink (which, btw, is easy to do). Below is the code for my custom event sink:
public class DebugEventSink : EventSink
public DebugEventSink(IDictionary parameters, EventSource eventSource) : base(parameters, eventSource)
string param = parameters["columns"] as string;
if (param != null)
columns = param.Split(",".ToCharArray());
// Output the eventToRaise out to the debugger.
public override void Write(object eventToRaise)
StringBuilder sb = new StringBuilder();
Type t = eventToRaise.GetType();
foreach (string column in columns)
PropertyInfo pi = t.GetProperty(column);
if (pi != null)
sb.Append(" : ");
Once I had created my custom event sink I could now add it to the EnterpriseInstrumentation.config file, setting the columns I wanted to output, and now DebugView is outputting the data I want to see. The nice thing is that I can turn this on when I want to debug something, turn it off when I don't, or just have it write to the EIF trace log so I can look at things later on.
All in all, very cool. I am now a fan of EIF and I owe some thanks to the FABRIQ crew for showing me this. Thanks!