Debug / Trace Messages Using ELMAH in an MVC Application

How to add debug / trace messages using ELMAH in MVC application

+5
source share
2 answers

Elmah will automatically catch unhandled exceptions.

By tracing, I think, you mean logical exceptions which are processed?

If you want to manually log processed exceptions, the process in MVC is the same as for ASP.NET:

Add the Elmah DLL reference to your project, and then use Elmah.ErrorSignal.FromCurrentContext().Raise(), for example:

try
{
    throw new ApplicationException("raised for elmah to catch");
}
catch (System.ApplicationException ae)
{
    Elmah.ErrorSignal.FromCurrentContext().Raise(ae);
}
+5
source

ELMAH is typically used to report exceptions, and not as a general Debug / Trace log.

Debug/Trace log4net Log4PostSharp.

+5

All Articles