ELMAH not logging when customErrors On (ASP.NET MVC 3 RTM)?

2,501 views
Skip to first unread message

Ryan W

unread,
Jan 17, 2011, 3:54:15 PM1/17/11
to ELMAH
I just installed ASP.NET MVC3 RTM on our test server Friday and now
today, I'm not getting any error notifications. Everything seemed to
be ok prior to this (with the ASP.NET MVC3 beta and RC), but maybe
it's just a terrible coincidence. I don't use the HandleError
attribute at all in my app.

When customErrors = Off, the errors log in memory, email is sent,
etc.

When cusomErrors = On or RemoteOnly, no errors are logged, no email is
sent
(but 404 errors do still log with ELMAH)

Here's my custom errors section:

<customErrors mode="RemoteOnly" defaultRedirect="/Error/
ApplicationError.aspx" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="/Error/NotFound.aspx" />
</customErrors>

Anybody else seeing this?





Atif Aziz

unread,
Jan 20, 2011, 2:40:18 PM1/20/11
to el...@googlegroups.com
When cusomErrors = On or RemoteOnly, no errors are logged, no email is sent (but 404 errors do still log with ELMAH)

Sounds like ELMAH is essentially working since you say 404s are being logged. Try these troubleshooting hints: 
  • Enable ASP.NET tracing to see if ELMAH is logging internal errors and which you can subsequently view through trace.axd. It may give hints about what's going wrong.

  • If you added any error filtering then disable it temporarily (by commenting out the relevant section of the configuration file) just to eliminate the possibility that the errors may be getting filtered & therefore never getting logged or mailed.

  • Check that you're not using another similar library or that your own code is not clearing the error before ELMAH gets to see it.

  • If you're expecting errors during web service calls to be logged then that doesn't happen out-of-the-box as most web service frameworks usually catch the exception to be reported to the client. 

- Atif 






--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elmah?hl=en.


Ryan W

unread,
Jan 20, 2011, 3:59:25 PM1/20/11
to ELMAH
Thanks for the ideas.

In looking at this more, it looks like the change with the MVC 3 RTM
was in the Visual Studio template for Global.asax.cs. There is now
this:

public static void RegisterGlobalFilters(GlobalFilterCollection
filters)
{
filters.Add(new HandleErrorAttribute());
}

protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}

So, I lied, the HandleError Attribute was in effect and that is why
Elmah was silent. After removing that, elmah is logging again.

It's frustrating though that the ASP.NET error response generates a
200 HTTP status code for the error page after removing that filter
from global.asax.cs whereas it was giving a 500 status with the filter
in place. Achieving the goal of 1) custom error page with 500
response (no 302, no 200) and logging of error with Elmah proving much
are complicated than anticipated.

More digging, but at least elmah is working as it should. Thanks
again!


On Jan 20, 11:40 am, Atif Aziz <aziza...@gmail.com> wrote:
> > When cusomErrors = On or RemoteOnly, no errors are logged, no email
> > is sent (but 404 errors do still log with ELMAH)
>
> Sounds like ELMAH is essentially working since you say 404s are being
> logged. Try these troubleshooting hints:
>
>    - Enable ASP.NET tracing to see if ELMAH is logging internal errors and
>    which you can subsequently view through trace.axd. It may give hints about
>    what's going wrong.
>
>    - If you added any error filtering then disable it temporarily (by
>    commenting out the relevant section of the configuration file) just to
>    eliminate the possibility that the errors may be getting filtered &
>    therefore never getting logged or mailed.
>
>    - Check that you're not using another similar library or that your own
>    code is not clearing the error before ELMAH gets to see it.
>
>    - If you're expecting errors during web service calls to be logged then
> > elmah+un...@googlegroups.com <elmah%2Bunsu...@googlegroups.com>.

Ryan W

unread,
Jan 20, 2011, 4:32:42 PM1/20/11
to ELMAH
Thinking about this some more. I think there is a problem for Elmah,
but maybe more educational, since it's the MVC team's doing. Elmah is
advertised as just drop it in and it works, no code to change. But,
the fact is, with MVC 3 and the global handle error filter in place,
Elmah will not work out of the box for an MVC 3 app with custom errors
enabled.

Maybe the wiki needs a page about this, and perhaps the Stack Overflow
question is the place to ?

http://stackoverflow.com/questions/766610/how-to-get-elmah-to-work-with-asp-net-mvc-handleerror-attribute

Anyway, thanks again for the help.
Reply all
Reply to author
Forward
0 new messages