views:

87

answers:

3

I have two ASP.NET MVC web applications. One of them logs unhandled exceptions to the windows event log. The other doesn't.

Is there a setting in IIS or the web.config to enable event log logging?

Apologies for the broad question, I'm really looking for avenues for investigation.

+2  A: 

This is normally due to the account running the web application not having the right permissions to write to the event log.

In IIS 7, check the identity the application pool is running under.

Oded
Have ruled this out by setting the app pool for the site no logging, to the same pool as the site that is.
Ben Aston
+1  A: 

If the user running the webapp (the IIS user) isn't an admin, make sure that the event source is registered with the OS.

lance
This is correct, you need special permissions to create an event source (what ends up being a reg key) but to write to an event log (except security) you can be just about anyone. You probably need to create it with elevated privileges first.
Peter Oehlert
A: 

Turning CustomErrors on started stuff being added to error log.

Final solution was to add

<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>

to the

 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
...

Section of the web.config. This enabled Elmah in IIS7.

Loose understanding - exceptions were being intercepted by elmah, which was mal-configured for the above reason, causing swallowing of errors. Turning custom errors on, seemed to bypass elmah and enable errors to push through to event log.

Ben Aston