Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to log Code 500 Errors in ELMAH

On my ASP.NET 4.0 MVC project running in IIS 7 I have set up and configured ELMAH to log errors on my site. However, I am unable to get any reporting on errors with code 500.

I set up a simple controller that creates a divide-by-zero exception, but ELMAH does not log it. I can get ELMAH to log other messages just fine and I am not filtering out any exceptions in ErrorLog_Filtering.

In addition, to display the custom pages I have updated the httpErrors section of the web.config as follows:

<customErrors mode="RemoteOnly" defaultRedirect="~/error/GenericError">
  <error statusCode="403" redirect="~/error/AccessDenied" />
  <error statusCode="404" redirect="~/error/NotFound" />
  <error statusCode="500" redirect="~/error/Offline" />
  <error statusCode="501" redirect="~/error/Offline" />
  <error statusCode="503" redirect="~/error/Offline" />
</customErrors>

and

<system.webServer>
    <httpErrors errorMode="DetailedLocalOnly" >
        <error statusCode="403" prefixLanguageFilePath="" path="/error/AccessDenied" responseMode="ExecuteURL" />
        <error statusCode="404" prefixLanguageFilePath="" path="/error/NotFound" responseMode="ExecuteURL" />
        <error statusCode="500" prefixLanguageFilePath="" path="/error/GenericError" responseMode="ExecuteURL" />
        <error statusCode="501" prefixLanguageFilePath="" path="/error/GenericError" responseMode="ExecuteURL" />
        <error statusCode="503" prefixLanguageFilePath="" path="/error/Offline" responseMode="ExecuteURL" />

Finally, when reviewing the Application Log files, the code 500 error messages do not show there.

Is there a configuration I am missing or am I somehow accidentally trapping the error myself and not letting it propagate up?

like image 847
Cloud SME Avatar asked Aug 22 '10 04:08

Cloud SME


1 Answers

You need to delete the line adding the filter HandleErrorAttribute in RegisterGlobalFilters() in FilterConfig.cs. More details in this question.

like image 77
Nilzor Avatar answered Nov 17 '22 13:11

Nilzor