After Thought

Setting up Elmah in your application to log into FogBugz (Bug tracking system)

with 2 comments

ELMAH (Error Logging Modules and Handlers)  is a pluggable error logging system created by Atif Aziz that can be hooked onto an ASP.Net application. It is very straight forward to set up and gives options to log errors to several back-end storages including databases, in-memory, XML files and send out email notification. Scott Hanselman blogged about setting up ELMAH a while back. This is just an extension to that post to log the error to bug tracking system like FogBugz if you are using one.

Here is how to set up ELMAH on your ASP.Net MVC that logs an entry in FogBugz when there is an error. Fogbugz allows to log an error just by sending an email to the FogBugz connected mailbox. So we will set up ELMAH to send an email when there is an error.

Download ELMAH Core Binary and add it your library. Add a reference to Elmah.dll in your web project.

Add following entries to your web.config

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

<modules runAllManagedModulesForAllRequests="true">
 <add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule" preCondition="managedHandler" />
 <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
 <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
 <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah"/>

 <sectionGroup name="elmah">
 <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
 subject="<Application Name> Error"
 smtpServer="" />

That is it. ELMAH is set up and your application is ready to log any errors to FogBugz.

Before you proceed any further check if ELMAH is properly set up by going to http://localhost/elmah.axd. You should get the following screen.

You will still encounter yellow screen when there is an error. You can always redirect users to a nice looking page if there is an error by configuring your customErrors section as follows.

<customErrors mode="On" defaultRedirect="~/Error/SomeError">
 <error statusCode="404" redirect="~/Error/NotFound"/>

Written by shashankshetty

January 13, 2011 at 11:23 am

Posted in, MVC, C#, Uncategorized

Tagged with ,

2 Responses

Subscribe to comments with RSS.

  1. Hi, I’ve just started looking into how best to integrate these two.

    I’ve also been reading

    With your method, is the stack trace nicely formatted?

    OliverOgg (@OliverOgg)

    October 24, 2011 at 8:59 am

    • Stack trace is well formatted.


      October 27, 2011 at 3:35 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: