Question

I would like to log unhandled exceptions from the global.asax to the Application eventlog. However, I've noticed that IIS is already logging these unhandled exceptions as warnings. Is there a way to suppress these messages since I'm planning on logging them myself or do you think it’s reasonable to have both entries there (the event log entry logged by IIS and my event log entry)?

UPDATE:

Thank you John Saunders for pointing me in the right direction. It was in fact health montioring that was doing the logging based on the default configuration in the root web.config.

Was it helpful?

Solution

You would do better to find out what those entries are. They're not from IIS, they're from ASP.NET Health Monitoring.

That's an extensible mechanism, and you may want to extend it instead of rolling your own. For instance, it's trivial to conifgure it to also log application start and end, in order to keep track of AppDomain restarts. You can also add data tot he "web events" that it logs, and configure where the log information will be sent.

See ASP.NET Health Monitoring Overview.

OTHER TIPS

Here's a blog post I wrote a few months ago on using ASP.NET Health monitoring with ASP.NET MVC3.

http://mattfrear.com/2011/01/28/mvc3-logging-exceptions/

-Matt

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top