Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top