Elmah Signaling – How To Log Exceptions with Elmah but Continue Processing

Elmah is an excellent tool for web programmers. It is an extremely easy to install exception handler that logs application exceptions and sends the user to an “oops” page. It can also send an email to the developer or webmaster.

But what if you want to log an error but NOT send the user to an “oops” page. This can be especially useful in debugging code that already handles exceptions so that the user doesn’t see them.

Here is how it works:

Add a reference to Elmah to the page:

using Elmah;

Then, in your try/catch block, use this code:

    //some code}
catch (Exception ex)
    // handle your exception here
    ErrorSignal.FromCurrentContext().Raise(ex); //ELMAH Signaling  (logs error but processing continues)
    return false;  //assuming the method returns a boolean value.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s