Take the 2-minute tour ×

We have a console application that currently is using Log4Net & ELMAH. Log4net for logging exceptions and ELMAH for the unhandled exceptions. I have read that ELMAH is good tool to catch exceptions of applications without changing the code, but this is not our case. I am not sure this approach so my question is:

Is using ELMAH a good idea to deal with unhandled exceptions?

As I see it we shouldn't have unhandled exceptions at all. Having a Try/Catch in Main() function will catch all of them, won't it?

Or subscribing to UnhandledExceptionEventHandler?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Elmah just binds to UnhandledException for you (with a lot more infrastructure; ui, logging, message send-offs, configuration), but that's nothing you couldn't do yourself if you wanted to invest the time re-inventing the wheel.

though I was under the impression that Elmah was better suited for a web-based application, so to see it used in a console application makes me wonder if the added functionality (web-based log viewing) is really an added benefit at that point or isn't just overkill.

share|improve this answer
What do you refer by "re-inventing the wheel"? The idea is just catch all the exceptions and put them in the log repository. No fancy stuff as web ui as it is a console app... –  cad Jul 23 '13 at 13:34
@cad: Well, you either use elmah (which already has a database structure, logging mechanizsm, and filtering abilities out-of-the-box) or you create your own export/review mechanism (xml? db?) –  Brad Christie Jul 23 '13 at 13:35
Thanks. I got it. Seems in this case using ELMAH is an overkill. Log4net is enough... –  cad Jul 23 '13 at 13:36

Your Answer


