195 words
1 min
Quick Tip How To Manually Add A Log Entry In Elmah

Quick Tip

I’m a big fan of Elmah (even though I’m still a little more partial to log4Net since it gives you a very quick way of logging all unhandled exceptions in your application. However, sometimes you need to manually add an entry (say within a try/catch block) and fortunately Elmah provides a simple way to do that.

I should have looked through StackOverflow sooner, but here it is. Add this one statement in your catch block (or anywhere else really) and you can get a log entry into Elmah, and let your code continue as planned:

Elmah.ErrorSignal.FromCurrentContext().Raise(ex)

That’s all! Happy logging!

Quick Tip

I’m a big fan of Elmah (even though I’m still a little more partial to log4Net since it gives you a very quick way of logging all unhandled exceptions in your application. However, sometimes you need to manually add an entry (say within a try/catch block) and fortunately Elmah provides a simple way to do that.

I should have looked through StackOverflow sooner, but here it is. Add this one statement in your catch block (or anywhere else really) and you can get a log entry into Elmah, and let your code continue as planned:

Elmah.ErrorSignal.FromCurrentContext().Raise(ex)

That’s all! Happy logging!

Quick Tip How To Manually Add A Log Entry In Elmah
https://dillieo.me/posts/development/2012-07-24-quick-tip-how-to-manually-add-a-log-entry-in-elmah/
Author
Sean Patterson
Published on
2012-07-24
License
CC BY-NC-SA 4.0