0

I am sharing a simple solution for turning off Elmah sending emails for 404 Http Errors. I wanted elmah to still log the 404 errors in case we find some hackers trying to find some config files etc.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Rhys Stephens
  • 889
  • 3
  • 20
  • 36

1 Answers1

1

You need to add the following to your Web.config file:

system.web node:

<httpModules>
    ...
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
    <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    ...
</httpModules>

configSections node:

<sectionGroup name="elmah">
    <section name="errorFilter" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>

elmah node:

<errorFilter>
    <test>
        <and>
            <equal binding="HttpStatusCode" value="404" type="Int32" />
            <regex binding="FilterSourceType.Name" pattern="mail" />
        </and>
    </test>
</errorFilter>
Rhys Stephens
  • 889
  • 3
  • 20
  • 36