-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to log an error programmatically #30
Comments
Simplified summary line Reported by @atifaziz on 2007-08-21 20:09:19 |
This issue still needs to be addressed via perhaps a wiki page, but meanwhile here is some new information regarding logging programmatically (yes, cheap documentation)... The Calling Reported by @atifaziz on 2007-10-30 21:30:22 |
I was doing it as follows. Is there anything wrong with this? try
{
ds.WriteXml(xml);
}
catch (UnauthorizedAccessException uae)
{
Elmah.SqlErrorLog sqlErrorLog = new Elmah.SqlErrorLog(Common.Config.strCnn);
sqlErrorLog.Log(new Elmah.Error(uae, System.Web.HttpContext.Current));
//or even...
throw new Exception(string.Format("Could not write to the file {0}, maybe file is read only", xml), uae);
} Reported by |
There is nothing technically wrong with it but you'll be tying in to the Reported by @atifaziz on 2007-11-05 14:31:36 |
As of now, one way "to publish an exception to ELMAH programmatically" seems to be like this... Elmah.ErrorSignal.FromCurrentContext().Raise(new ApplicationException("my msg")); ...so that might help. -- Mark Kamoski Reported by @mkamoski on 2009-04-29 19:57:37 |
I'm trying this in v1.1, but I'd like to know if this is the approved way to do it Dim elmahError As New Elmah.Error()
elmahError.Message = "Something happened"
elmahError.Time = Date.Now()
Dim elmahErrorLog As Elmah.ErrorLog = Elmah.ErrorLog.GetDefault(HttpContext.Current)
elmahErrorLog.Log(elmahError) Reported by @MADCookie on 2009-10-12 22:39:21 |
@MADCookie: Signaling is the more recommended way to go. Reported by @atifaziz on 2009-10-12 22:43:17 |
Thank you. This is exactly what I was trying to find. Sorry I couldn't. Hopefully others will find what they need because of your response. I would like to add this link. It lists common exceptions to help those of us needing http://blogs.msdn.com/brada/archive/2005/03/27/402801.aspx Reported by @MADCookie on 2009-10-12 23:01:08 |
Hi
is it not possible to use this method in WCF Service? Reported by |
Maybe the priority on this needs to go up. See discussion here: http://groups.google.com/group/elmah/browse_thread/thread/9ea4b51420fd5dfa Reported by |
Can anyone please explain how I can resolve this issue #30 (comment) I'm facing the same problem. I cant understand anything on this discussion Reported by |
We should have a page to document how to publish an exception to ELMAH programmatically. Sometimes a developer inherits code that swallows an exception but still wants to publish it.
Originally reported on Google Code with ID 30
Reported by @haacked on 2007-08-21 17:06:58
The text was updated successfully, but these errors were encountered: