Error Handling Code seems to be ignored
I have the following code that executes fine in my dev environment but seems to be ignored or errors out in production:
global.asax
protected void Application_Error(object sender, EventArgs e)
{
try
{
LinqToColloqDataContext db = DataAccess.GetMWContext();
Log newLog = new Log();
System.Exception Thisex = Server.GetLastError();
newLog.Date = DateTime.UtcNow;
newLog.Exception = Thisex.ToString() + Thisex.StackTrace.ToString();
newLog.Level = "1";
newLog.Message = Thisex.Message;
newLog.Thread = "x";
newLog.Logger = "L";
db.Logs.InsertOnSubmit(newLog);
db.SubmitChanges();
}
catch (System.Exception ex)
{
int whattodonow = 1;
}
}
I don't know if it is not being hit because appharbor's config intercepts the call before it is called or if it is failing when I try to submit the linq query.
Not having any sort of access to event logs is getting really frustrating.
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by friism on 13 Feb, 2011 09:21 PM
Are you using MVC 3? By default, there's an
filters.Add(new HandleErrorAttribute());
in theRegisterGlobalFilters
method of yourGlobal.asax.cs
. If you remove that, your logging-method should be triggered.Let me know if this doesn't resolve your problem.
friism closed this discussion on 13 Feb, 2011 09:21 PM.
skilesare re-opened this discussion on 14 Feb, 2011 01:33 AM
2 Posted by skilesare on 14 Feb, 2011 01:33 AM
Actually, with mvc2 I had to add the custom error mode = off to my web.config. I guess it was using whatever you all have in the machine . Config file.
Support Staff 3 Posted by friism on 14 Feb, 2011 01:47 AM
OK, that would do it too.
friism closed this discussion on 14 Feb, 2011 01:47 AM.