Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

I installed from nuget elmah and elmah on XML log, didn't got the expected funcionality although I could access http://localhost/elmah.axd, but no error capturing.

I gave write permission to the account IIS_IUSERS in the folder APP_DATA and it started working for HTTP 404 errors and the errors that are outside MVC infrastructure. But it did not log exceptions inside the mvc. The solution was installing elmah.mvc package from nuget and it started capturing all exceptions.

If your config is OK, then just install the elmah.mvc package from nuget and it should start storing logs also inside mvc, not just HTTP 404.

The problem is this line

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

Replace it by

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top