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:
try { //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. }