Monday, February 7, 2011

Elmah - basic setup IIS 7 with MVC.Net

How to configure ELMAH.

  1. Copy elmah files to the bin folder
  2. Under section "configuration -> configSections" on your web.config, add these lines
    <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" />
  3. Under section "configuration" on your web.config, add these lines
        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
        <security allowRemoteAccess="1" />
  4. Under section "configuration -> system.web" on your web.config, add these lines

          <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  5. If you are running IIS 7, under section "configuration -> system.webServer" on your web.config, add these lines

    <modules runAllManagedModulesForAllRequests="true">
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
          <add name="elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
  6. If you are running MVC.Net, add this line of code to your register routes function on global.asax

    public static void RegisterRoutes(RouteCollection routes)
  7. You are now ready to view the logs. Go to

No comments:

Post a Comment