Skip to content

Instantly share code, notes, and snippets.

@friism
Created February 14, 2011 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save friism/825494 to your computer and use it in GitHub Desktop.
Save friism/825494 to your computer and use it in GitHub Desktop.
protected void Application_Error(object sender, EventArgs e)
{
try
{
var exception = Server.GetLastError();
var logEntry = new LogEntry
{
Date = DateTime.Now,
Message = exception.Message,
StackTrace = exception.StackTrace,
};
var datacontext = new LogDBDataContext();
datacontext.LogEntries.InsertOnSubmit(logEntry);
datacontext.SubmitChanges();
}
catch (Exception)
{
// failed to record exception
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment