We help IT Professionals succeed at work.

Can you configure IIS to log ASP.NET errors to the Event Log?

marvin_da_martian asked

I'm currently supporting an ASP.NET 2.0 website.  I'm trying to figure out how the site is logging ASP.NET errors to the Windows Event Log.  I checked all the possibilities where I know this may be done:

1) In Page_Error() for a particular page.
2) In Application_Error() in global.asax.
3) In an HttpModule that adds an Error event Handler.
4) In <customErrors> section that redirects.

None of the above were being used to log to the EventLog.

Moreover, I did a global search on "EventLog" on the entire code base, and found nothing.

Is there another way I could where event logging was setup?  Can it be done through IIS?  In the registry?  In the IIS Metabase?  Somewhere else?

Once again, it was NOT done anywhere in the ASP.NET code from I've researched.


Watch Question

You can catch the exception in Application _Error and custom  log the error in Event Log.

Enterprise library application blocks Logging Handler  provides Logging to event logs.


Like I said, the application is not using Application_Error().
Its also not using log4net, nor is it using Enterprise Library app blocks for logging.
Implement Application_Error in global.asax
Find out the last error and convert into base exception.

Then log the the exception to event log as described in the article ( http://imar.spaanjaars.com/275/logging-errors-to-the-event-log-in-aspnet-applications )
u can this from a number of ways:
1. write a custom error handler module, synchronize this event in httphandler to add error in event viewer   http://www.15seconds.com/issue/060406.htm
2.Add Application_Error through global.asax : http://imar.spaanjaars.com/275/logging-errors-to-the-event-log-in-aspnet-applications
Since nobody was actually *READING* my post - I researched the answer myself.  By default, the global ASP.NET 2.0 web.config (found in: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config) is configured with the <healthMonitoring> configuration, which logs unhandled exceptions as Warnings to the event log.