Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Exception Handling/Logging

Is there an easy way to log all exceptions in an ASP.NET application? I'm already logging unhandled exceptions through the Application_OnError event, but I want to perform logging even when an exception is handled on a page level.

Many thanks.

like image 967
staterium Avatar asked Jul 15 '09 07:07

staterium


People also ask

How do I log exceptions in Web API?

Today there's no easy way in Web API to log or handle errors globally. Some unhandled exceptions can be processed via exception filters, but there are a number of cases that exception filters can't handle. For example: Exceptions thrown from controller constructors.

How exceptions are handled in ASP.NET application?

Exception class. An exception is thrown from an area of code where a problem has occurred. The exception is passed up the call stack to a place where the application provides code to handle the exception. If the application does not handle the exception, the browser is forced to display the error details.

What is log exception in C#?

The LogException (Exception, String, String, Boolean) method logs an exception with information about the calling method, when the exception occurred, and whether the exception was caught and handled.

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.


1 Answers

You could use Elmah to log your exceptions. It's really easy to use and gives good information about the problem.

like image 114
Richard L Avatar answered Sep 28 '22 01:09

Richard L