I have added logging to a web application (using the Enterprise Library framework) so exceptions are recorded in the application event log. I have given the event has a source called "WebApp" but this isn't being recorded as the source doesn't exist.

Is there a way to manually add a new event source? I have found some examples on stackoverflow but these require creating custom install applications so before I go down this road I'm wondering if there is a simpler method.


You need to add the source in the code of your web application, using:

System.Diagnostics.EventLog.CreateEventSource("MyApp1", "Application");


  • Thanks. I take it there isn't a way to do this from the server console? – Keith Bloom Aug 6 '09 at 10:35
  • Not that I know of i'm afriad – Sam Cogan Aug 6 '09 at 10:44
  • In that case I don't think there is. In to the code it goes. – Keith Bloom Aug 6 '09 at 10:46

If you use PowerShell you can create the event source from the console like this:

[System.Diagnostics.EventLog]::CreateEventSource("MyApp1", "Application")

If you don't have it installed as a feature in WS 2008, you should.

  • Since your event source only needs to be 'registered' once, this would be the proper way to do it. Once it's registered, you can then produce multiple events from this source, with different event ID's and descriptions, based on how the app behaves. – George Erhard Dec 28 '16 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.