ELMAH: Error Logging Modules and Handlers for ASP.NET is a pretty awesome error logger. I've installed it on a couple sitefinity instances so I figured I'd blog about it to help some others with it.

If you've never seen it, here are a couple resources:

  1. Scott Hanselman
  2. Detailed Setup Document

It's an HttpModule which intercepts all crashes and logs them to a single table in your database, then provides a nice simple interface (and rss feed) to see the log items.

STEP 1

Web.Config Updates

web.configView on GitHub
<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"/>
    </sectionGroup>
....
 

<!-- THIS IS THE CONFIG SECTION DESCRIBED ABOVE --> <elmah> <security allowRemoteAccess="1"/> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Sitefinity" /> <errorMail from="noreply@example.com" to="elmah@example.com" priority="high" /> </elmah>

<!-- SETUP THE HANDLERS FOR IIS6 --> <httpHandlers> <add verb="POST,GET,HEAD" path="/sitefinity/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/> ...

<httpModules> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> ...

<!-- OR HANDLERS FOR IIS7--> <modules> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/> ...

<handlers> <remove name="ErrorLog" /> <add name="Elmah" verb="POST,GET,HEAD" path="/sitefinity/elmah.axd" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah"/>

<!-- PLACE AFTER SYSTEM.WEB, RESTRICTS ACCESS TO ADMINS ONLY --> <location path="sitefinity/elmah.axd"> <system.web> <authorization> <allow roles="administrators" /> <deny users="?"/> </authorization> </system.web> </location>

STEP 2

SQL Script to create the table (included in the download file in the db folder)

STEP 3

Copy the Assemblies to your bin folder (ignore the SqlLite and VistaDB dlls)

Now you can visit https://www.yoursite.com/Sitefinity/elmah.axd, log in, and hopefully see no errors ;)