Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhandled ASP.NET Errors - any logging available?

We've had an issue where a .NET error occured at the root of our application cluster that bypassed our error handling and was displaying the generic ASP.NET error message.

Is there anywhere to check to see these errors if it bypassed our logging of them? (Default .NET/IIS logging or anything?)

Thanks.

like image 849
Ryan Ternier Avatar asked May 17 '11 19:05

Ryan Ternier


People also ask

What is error logging in asp net?

ELMAH (Error Logging Modules and Handlers) is an error logging facility that you plug into your ASP.NET application as a NuGet package. ELMAH provides the following capabilities: Logging of unhandled exceptions. A web page to view the entire log of recoded unhandled exceptions.

Which of the following is the easiest way to track all unhandled errors?

An ExceptionFilterAttribute is used to collect unhandled exceptions. You can register it as a global filter, and it will function as a global exception handler. Another option is to use a custom middleware designed to do nothing but catch unhandled exceptions.

Where do I find unhandled exceptions?

View Unhandled Exceptions in Windows Event Viewer If your application has unhandled exceptions, that may be logged in the Windows Event Viewer under the category of “Application”. This can be helpful if you can't figure out why your application suddenly crashes.

Which is the best way to handle errors in net?

Error handling in ASP.NET has three aspects: Tracing - tracing the program execution at page level or application level. Error handling - handling standard errors or custom errors at page level or application level. Debugging - stepping through the program, setting break points to analyze the code.


3 Answers

You should be able to check the Application Event Viewer.

  1. Right-click My Computer
  2. Manage
  3. Event Viewer
  4. Application

The assumption here is that it bubbled up and didn't get caught anywhere.

like image 198
Joe Phillips Avatar answered Oct 04 '22 07:10

Joe Phillips


// Inside your logger constructor:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomainUnhandledException);

// Then:
private void AppDomainUnhandledException(Object sender, UnhandledExceptionEventArgs e)
{
    // Log as unhandled exception: e.ExceptionObject.ToString()
}
like image 45
Xaqron Avatar answered Oct 04 '22 05:10

Xaqron


If you are using IIS7 you can add failed request tracing via IIS Manager. See the following article for more information:

http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-7/

like image 45
Rob Avatar answered Oct 04 '22 05:10

Rob