views:

1915

answers:

1

FYI: ELMAH is the Exception logging framework that is mentioned on Coding Horror here.

How do I setup / configure ELMAH on GoDaddy ASP.NET hosting? I seem to get 404 errors when trying to access elmah.axd. I have followed all of the instructions here to modify my web.config and bin deploy the Elmah assembly.

I was using the BETA 2 binary download listed here: http://code.google.com/p/elmah/downloads/list

+7  A: 

Ah ha! I've got it working now, and I wanted to share what I did to get up and running (it's not entirely obvious).

  1. First, get the latest release of ELMAH here: http://code.google.com/p/elmah/ (I ended up using the BETA3 release which was just released today, incidentally. Props to the ELMAH devs. The download I grabbed was the ELMAH-1.0-BETA3-bin drop.
  2. Unzip that to a location on your disk
  3. Look in the ELMAH-1.0-BETA3-bin\samples directory for web.config and open this in an editor. (There is a LOT of html comments in this file explaining the different entries -- a color coding IDE / editor is very useful here.)
  4. The section (about 3/4 of the way down the config) that starts with 'The section is required for running ELMAH under Internet Information Services 7.0' is VERY important. This is the config section you'll be using.

GoDaddy uses IIS 7.0 for its .NET 2.x/3.x ASP.NET hosting, so it's important that you use the system.webServer section, not the system.web section.

I have used the following config sections and added them to the appropriate places in my web.config:

<configSections>
    <sectionGroup name="elmah">
        <!-- NOTE! If you are using ASP.NET 1.x then remove the
             requirePermission="false" attribute from the section
             elements below as those are only needed for
             partially trusted applications in ASP.NET 2.0 -->
        <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>

<elmah>
    <security allowRemoteAccess="true" />
    <!--
        Use to log errors into separate XML files that are stored on 
        disk at the path specified in the logPath attribute.
    -->
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />

</elmah>

<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>

One final note: *If you're using xml based logging (like I am) make sure the App_Data directory exists off your root web directory.*

The end result of this configuration is that I can use ELMAH to view exceptions that occur in prod (and are logged by ELMAH), but since I can't use ELMAH in the local ASP.NET development server. I think this is a good trade-off since I can see exceptions locally in Visual Studio.

*Update 12/9/08 - For some reason, I haven't been able to figure out how to write *.xml files to app_data, so I switched to the SQL logger. Just be sure to run the .sql script in your database that you configure.*

Dan Esparza