Elmah basic setup questions/issues

Mike picture Mike · Jun 6, 2009 · Viewed 10.9k times · Source

I'm not finding this to be easy to setup; either there is a missing step in the setup configuration, it isn't work correctly, or I don't actually understand it's purpose. There is something definitely wrong here. The problem must obviously be me. I'm just not getting this to work. Here's what I've done.

Create a brand new mvc application. Placed the following on the About.aspx page.

<% throw new Exception("blah"); %> Put content here.

Hit the page get the yellow screen with the exception.

Add elmah.dll to bin directory.

Add to the Web.config file configurationSections:

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

Add to the httpHandlers section the following:

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

Add to the modules section:

<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>

Add to the handler section:

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

Add an elmah section:

<elmah>
  <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>

What is curious here is that the ".XmlFileErrorLog" part of that string show up red as a ReSharper error indicating that it "Cannot resolve symbol '.ctor'" which when I look at the elmah.dll in Reflector shows this object to require either a "string" or an "IDicationary" in either of the two public constructors.

I'm running Windows Vista x64 with VS 2008. Set permission on the App_Data to Everyone as Co_Owner.

The http://localhost:xxxx/elmah.axd page does come up and shows no errors. When I hit my "About" page again I still see yellow screen and elmah.axd still shows no errors the app_data folder .

I substituted the customerrors with and created associated page:

<customErrors mode="On" defaultRedirect="GenericErrorPage.htm" />

The custom page shows but elmah.axd still shows "No Errors". App_data still empty!

As source to start this setup I used: code.google.com/p/elmah/wiki/MVC

So where am I messed up at?

~-=Mike=-~

Answer

eu-ge-ne picture eu-ge-ne · Jun 7, 2009

Check if ErrorLogModule is present in both configuration/system.web/httpModules (used if you are on Development Web Server) and configuration/system.webServer/modules (used by IIS7). Here is the fragment of web.config from project, I'm currently working on:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
        </httpModules>
    </system.web>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="ErrorLog" />
            <remove name="ErrorMail" />
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
        </modules>
    </system.webServer>
</configuration>

Hope this helps