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>
<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"/>
</sectionGroup>
</configSections>
Step 3: Add the ELMAH Section
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.XmlFileErrorLog,Elmah" logPath="|DataDirectory|" />
</elmah>
Step 4: System.web—httpModules and httpHandlers
<system.web>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule,Elmah"/>
</httpModules>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory,Elmah" />
</httpHandlers>
</system.web>
Step 5: (II7 Only) Configure system.webServer
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<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" />
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory,Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
Step 6: Secure remote access using ASP.NET membership
<location path="elmah.axd">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
Resources: