Does ELMAH logged exceptions even when they do not bubble up to the application? I'd like to pop up a message when an exception occurs and still log the exception. Currently I've been putting everything in try catch blocks and spitting out messages, but this gets tedious.
Asked
Active
Viewed 1.5k times
2 Answers
129
ELMAH has been updated to support a new feature called Signaling.
This allows you to handle exceptions how you want, while still logging them to ELMAH.
try
{
int i = 5;
int j = 0;
i = i / j; //Throws exception
}
catch (Exception ex)
{
MyPersonalHandlingCode(ex);
ErrorSignal.FromCurrentContext().Raise(ex); //ELMAH Signaling
}
Re-throwing exceptions can be a bad practice as it makes it difficult to trace the flow of an application. Using Signaling is a much better approach if you intended to handle the error in some fashion and simply want to document it.
Please check out this excellent guide by DotNetSlackers on ELMAH

Atif Aziz
- 36,108
- 16
- 64
- 74

Michael La Voie
- 27,772
- 14
- 72
- 92
-
8is it possible to achieve that using some kind of attribute/filter? Because to put that code inside each catch it is to much i think, it would be good to have such kind of filter which would do that. – angularrocks.com Sep 20 '11 at 00:39
-
ironically that dognetslackers link leads to an unhandled error page. This has to be a troll? – niico Feb 13 '17 at 15:32
-
here's a wayback machine link to the DotNetSlackers article: http://web.archive.org/web/20140415040316/http://dotnetslackers.com/articles/aspnet/ErrorLoggingModulesAndHandlers.aspx – XoXo Oct 02 '19 at 12:41
6
A filter is the cleanest way to handle this problem. Check this solution here https://stackoverflow.com/a/5936867/965935
-
2As far as I understand a filter will not be able to catch an exception already handled in a try catch block. Check this answer here [link](http://stackoverflow.com/a/21864117/694457). – frezq Jan 14 '15 at 09:27