views:

1320

answers:

2

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

+8  A: 

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

eu-ge-ne
This did it! Thank you! It was missing in the <httpModules> section.
Mike
Thanks.. that documentation needs to get updated. Still.
stimpy77
+2  A: 

Try removing this section:

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

This will mean that Elmah is setup to just use the default in-memory logging. This help trouble shooting because you know it isn't a file permission thing. So once you've got it working with in-memory logging you can then set it up to log to a xml file.

You may also want to check out this stackoverflow question, How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?, that was answered by Atif Aziz himself.

HTHs, Charles

Charlino