5

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.

4
  • Do you get the standard Yellow Screen of Death in both apps? What version of IIS/Windows? Commented Mar 17, 2010 at 13:40
  • No ysod - friendly error message displayed. I see the same behavior on win2k3/iis6(?) and server2k8/iis7 Commented Mar 17, 2010 at 13:48
  • @Ben Aston - and the error message is? Commented Mar 17, 2010 at 14:10
  • @Ben Aston - Do you have an unhandled exceptions handler? What does it look like? Commented Mar 17, 2010 at 14:11

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Have ruled this out by setting the app pool for the site no logging, to the same pool as the site that is.
@Oded does NetworkService built-in account has permissions to write to event log?
@myroslav - it can, so long as it uses existing event sources. It doesn't have enough registry permissions to create new even sources.
@Oded sorry about that. Thank you for the answer. This was helpful, my website was running under NetworkService account and therefore no events were written to the log when 500 error occurred.
1

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

1 Comment

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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.