Pages

Tuesday, April 17, 2012

Elmah Error Loging Module and Handler for Asp.net

Introduction
            ELMAH is an open source project used to add error logging capabilities to an ASP.NET Web application. ELMAH essentially provides a means for logging and reporting unhandled exceptions in applications. I came across this very nifty tool while working with the MASS LEG team to create the Legislative Automated Workflow System (LAWS) application for the Massachusetts Legislature. We used ELMAH to uncover issues in the application that were producing unhandled and non-descriptive exceptions.  Using ELMAH, the dev team was able to use the stack trace of the exception to pinpoint and fix the problem. The following provides a brief description of how to set up ELMAH and enable & configure its error logging.
Link for tutorial:
Integrating ElMAH in asp.net is preety straight forward:
1. Download ELMAH and add the Elmah.dll assembly to your web application, 
2. Register ELMAH's HTTP Modules and Handler in Web.config,
3. Specify ELMAH's configuration options, and
4. Create the error log source infrastructure, if needed.

Follow instruction in tutorial, Your Final web config may look lik this:



After you change your web.Config add reference of elmah.dll to your Bin directory and create the table ELMAH_Error in sqlserver

You can execute the sqlserver.sql file in order to create table and store procedures.. and its done :)
you can see the logs by adding elmah.axd in root directory like
www.example.com/elmah.axd or localhost/something/elmah.axd
good luck