Logging Errors with ELMAH in ASP.NET MVC 3 – Part 2 – (Notifications)

Tags: Elmah, ASP.NET, MVC, Logging, Error Handler

Setup Notifications for ELMAH Errors

Now that ELMAH is setup, you need a way to be notified when an error occurs. Though you can just subscribe to your ELMAH RSS feed at /elmah.axd/rss, I prefer to receive an email notification as soon as an error happens. To do this simply merge the following changes into your web.config's <configuration> section.

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

<system.webServer>
  <modules>
    <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
  </modules>
</system.webServer>

<elmah>
  <errorMail from="e@mail.address"
             to="e@mail.address"
             subject="elmah error mail" />
</elmah>

There's a lot more configurability, but those are the basics. Here's a good article showing more options. Also if you haven't already done it, set your smtp settings too...

<system.net>
  <mailSettings>
    <smtp>
      <network host="localhost" />
    </smtp>
  </mailSettings>  
</system.net>

Next Step: Logging Errors with ELMAH in ASP.NET MVC 3 – Part 3 – (Filtering) »

This Post is Part of a Multi-Part Series

Add a Comment