Elmah not working with asp.net site

I just had a similar problem with Elmah not working in an IIS7 deployment. I found that I needed to register the Elmah Modules and Handlers in system.web AND system.webServer: <system.web> … <httpHandlers> … <add verb=”POST,GET,HEAD” path=”elmah.axd” type=”Elmah.ErrorLogPageFactory, Elmah” /> … </httpHandlers> <httpModules> … <add name=”ErrorLog” type=”Elmah.ErrorLogModule, Elmah”/> <add name=”ErrorMail” type=”Elmah.ErrorMailModule, Elmah” /> <add name=”ErrorFilter” … Read more

How to use ELMAH to manually log errors

Direct log writing method, working since ELMAH 1.0: try { some code } catch(Exception ex) { Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex)); } ELMAH 1.2 introduces a more flexible API: try { some code } catch(Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } There is a difference between the two solutions: Raise method applies ELMAH filtering rules to the exception. Log method … Read more

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

You can subclass HandleErrorAttribute and override its OnException member (no need to copy) so that it logs the exception with ELMAH and only if the base implementation handles it. The minimal amount of code you need is as follows: using System.Web.Mvc; using Elmah; public class HandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute { public override void OnException(ExceptionContext context) { … Read more