Trying to send exceptions to ELMAH2 "manually"

311 views
Skip to first unread message

mscheuner

unread,
Sep 4, 2006, 11:56:06 AM9/4/06
to ELMAH
Folks,

I'm beginning to use ELMAH in my ASP.NET 2.0 app to capture exception
info to a more manageable format.

It works okay for exceptions that aren't already trapped and handled
anywhere - those are being recorded, and sent to my error reporting
e-mail address just fine.

My question now is: all throughout my app, I have tons of calls to a
central method which currently logs exceptions to a text file. This is
rather hard to handle and not very manageable at all.

What I'd like to do is tap into that central method, and grab those
exceptions into ELMAH, too - with the e-mail being sent and all.

How can I do that? If I can do that at all?

Thanks for any hints / pointers / thoughts!

Marc

Scott Wilson

unread,
Sep 4, 2006, 2:24:48 PM9/4/06
to el...@googlegroups.com

> What I'd like to do is tap into that central method, and grab those
> exceptions into ELMAH, too - with the e-mail being sent and all.

You can manually log an error with Elmah with this one-liner:

GotDotNet.Elmah.ErrorLog.Default.Log(new Error(new Exception("your
errormessage here")));

or, if you're catching an Exception called e:

GotDotNet.Elmah.ErrorLog.Default.Log(new Error(e));

-s

Atif Aziz

unread,
Sep 4, 2006, 3:53:51 PM9/4/06
to el...@googlegroups.com
Scott's right on with his suggestions.
Also, check out the following thread from the older ELMAH discussion
board around the same theme:

http://shrinkster.com/hz5

- Or -

http://www.gotdotnet.com/workspaces/messageboard/thread.aspx?id=f18bab11
-162c-4267-a46e-72438c38df6f&threadid=e0410198-6e6c-4dc0-8fc7-182c2996a1
d6

mscheuner

unread,
Sep 5, 2006, 9:37:55 AM9/5/06
to ELMAH
Thanks, Scott and Atif, for your response and hints - works like a
charm now!

Excellent stuff.

Marc

Reply all
Reply to author
Forward
0 new messages