Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



EIF and DebugView

Posted in General at Thursday, September 30, 2004 5:42 AM Pacific Daylight Time

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
  string[] columns;

  public DebugEventSink(IDictionary parameters, EventSource eventSource) : base(parameters, eventSource)
    if (parameters.Contains("columns"))
      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(pi.GetValue(eventToRaise, 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!

Tuesday, October 12, 2004 9:18:00 PM (Pacific Daylight Time, UTC-07:00)
If you like that, then take a look at the <a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/Logging.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/Logging.asp</a>
<br>And if you prefer something arguably better than EIF/MLAB then take a look at log4net at: <a target="_new" href="http://sourceforge.net/projects/log4net/">http://sourceforge.net/projects/log4net/</a>
<br>Personally I think log4net is best, but that is my background and it comes preloaded with loads of event sinks and is very simple to use. Either way they are both essential to an enterprise solution.
Monday, November 1, 2004 6:52:00 PM (Pacific Standard Time, UTC-08:00)
I tried almost the same thing, but I keep getting the following error:
<br>Unable to read and validate the configuration file C:\Data\Personal\Tech-Ed\EIF\EIF\EnterpriseInstrumentation.config. The following type(s) cannot be loaded:
<br> CustomSink.FileEventSink
<br>Please check the event & eventSink element's type attribute in the configuration file, and that these types are correctly installed on the system.
<br>Where else do I look to see where I went wrong?
Peter Munnings
Monday, November 6, 2006 4:41:05 PM (Pacific Standard Time, UTC-08:00)
I have implemented logging in the same way you are doing.
I am able to invok constructor of the CustomEventSink but i want to invoke different function instead.

Please tell me what changes I need to do in EnterpriseInstrumentaion.config file?

Monday, November 6, 2006 4:48:36 PM (Pacific Standard Time, UTC-08:00)
Please add a reference of the Custom sink project to your web project
Monday, March 2, 2009 7:52:54 PM (Pacific Standard Time, UTC-08:00)

I got the Same Error:

The following type(s) cannot be loaded:
Please check the event & eventSink element's type attribute in the configuration file, and that these types are correctly installed on the system.

I used gacutil to register the costum sink but i still the same error any ideas ?

Thnx. Greg
Gregor N. Wellner
Comments are closed.