Oct 27, 2009

ELMAH for live website diagnosis.

It's the Firebug of Webservers.

Some of the tricky problems with live websites are
- Unhandled server side exceptions
- Environmental issues that can't be logged at application level

Diagnosis for these would require turning off the custom errors and limiting to local server. But, this doesn't do live monitoring of errors for you to look back the errors.

ELMAH helps monitor the websites for unhandled exceptions. The best part is that, it requires only few config changes to get plugged into your website and monitor for errors.

I have been using it on IIS for live site diagnosis, which is crucial for production sites. For my ASP.NET website, i did the following to plug in the ELMAH.

1) Download ELMAH online. Just google!
2) Add the following keys to the web config file under key. If you already have httpHandlers and httpModules keys, then just add the child nodes to them.

    <httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
    </httpHandlers>
    <httpModules>
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
    </httpModules>
3) Copy the following ELMAH files to your website bin directory
Elmah.dll, Elmah.pdb, Elmah.xml

4) Browse the url "http://localhost/yourwebsite/elmah.axd" to see the ELMAH page. 

Snapshot below.








Tons of articles have been written about ELMAH. Few you might want to read:

ELMAH home page

Hanselman blog article

Dotnetslackers blog post
Reblog this post [with Zemanta]

No comments:

Post a Comment