Search code examples
asp.net-mvcasp.net-mvc-3elmahelmah.mvcelmahr

Send error email if only 404 using Elmah with MVC 4.5


My webconfig has something like this... and I wanted to filter so I only capture 404 errors to my email .. I am using MVC so what is the best way to do that..?

thanks

First time using Elmah

   <configuration>
   ...

   <system.web>
   ...

   <httpModules>
   ...

   <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
   <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
   </httpModules>
   </system.web>

  <system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules>
  ...

 <add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
 <add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule" preCondition="managedHandler" />
 </modules>

   ...
   </system.webServer>
   </configuration>

and then

  <elmah>
   <errorMail
        from="[email protected]"
        to="[email protected]"
        subject="my app Error" />

Solution

  • Check these:

    ELMAH - Filtering 404 Errors https://code.google.com/p/elmah/wiki/ErrorFiltering#Filtering_Declaratively_via_Configuration