blog.averetek

.NET musings, news, and product reviews courtesy of the Averetek development team.

Tuesday, September 25, 2007

 

Creating a New Event Log Source for ASP.NET

I was trying to set up error handling for a web app using the Windows event log and ran into trouble creating a new source. This code:


string SourceName = "New Test Source";

if (!System.Diagnostics.EventLog.SourceExists(SourceName))
  System.Diagnostics.EventLog.CreateEventSource(SourceName, Application");


which has successfully run in the past, now throws a security error. Apparently ASPNET doesn't have permission to read the Security event log. Probably picked up in some recent security update.

I tried adding relevent permissions, but still ran into trouble. Reluctantly, I followed the advice under "First Approach" at http://support.microsoft.com/kb/329291 and proceeded to manually add my new source directly to the registry. Worked like a champ, and now I'm back on the road again.

To avoid a little message in each entry protesting lack of info about event IDs, add a string for EventMessageFile. I used C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll.

Labels: , ,


Comments: Post a Comment



<< Home

Archives

January 2006   February 2006   April 2006   June 2006   September 2007  

This page is powered by Blogger. Isn't yours?