0

I am following this article to log errors to an XML file using ELMAH. I added the elmah.dll to the bin of my web application and modified the web config as below. But I do not find any xml file in App_Data folder.

Web Config

    <configSections>
        <sectionGroup name="elmah">
            <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
        </sectionGroup>
    </configSections>

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

    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <customErrors mode="On" defaultRedirect="Error.html"> </customErrors>
        <httpHandlers>
            <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        </httpHandlers>
        <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
        </httpModules>
        <httpRuntime/>
    </system.web>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>

</configuration>

Note: validateIntegratedModeConfiguration is added to avoid An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode error

Code behind

 protected void Page_Load(object sender, EventArgs e)
 {
      throw new InvalidCastException();
 }

It is also given that I can find the log using http://localhost/Elmah.Articel.web/elmah.axd. So i tried http://localhost:61276/elmah.axd but it throws 404 error.

Gopi
  • 5,656
  • 22
  • 80
  • 146

1 Answers1

1

Try the following, i using as this way,

<elmah> 
<security allowRemoteAccess="false" /> 
</elmah>

 <location path="elmah.axd" inheritInChildApplications="false">
<system.web>
  <httpHandlers>
    <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
  </httpHandlers>     
</system.web>
<system.webServer>
  <handlers>
    <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
  </handlers>
</system.webServer>
 </location>
hm27
  • 111
  • 5