Adding ELMAH to an ASP.NET Site

ELMAH (Error Logging Modules and Handlers)is a fantastic library that provides error logging and troubleshooting support toan ASP.NET web site. You practically just drop it in and BOOM, you’ve got great exceptionreporting.

Step 1: Add A Reference

Add a reference to the ELMAH DLL in your ASP.NET project. (They tell me it just needsto be dropped in the BIN folder, but that almost seems like more work to me.)

Step 2: Add Config Sections

In web.config, add the following lines to <configSections>

<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler,Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler,Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler,Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler,Elmah"/>

Step 3: Add the ELMAH Section

<security allowRemoteAccess="0" />
<errorLog type="Elmah.XmlFileErrorLog,Elmah" logPath="|DataDirectory|" />

Step 4: System.web—httpModules and httpHandlers

<add name="ErrorLog" type="Elmah.ErrorLogModule,Elmah"/>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory,Elmah" />

Step 5: (II7 Only) Configure system.webServer

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

Step 6: Secure remote access using ASP.NET membership

<location path="elmah.axd">
<deny users="?"/>



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