Installing ELMAH - no errors get caught

I installed ELMAH exactly as in the sample application. I am trying to execute an error for ELMAH validation using:

throw new InvalidOperationException();

      

Unfortunately my application goes straight to the error and ELMAH does not break / log the error. I am using ASP.NET 3.5. I'm not sure what I am doing wrong as the Web.Config is exactly the same as the sample

+2


source to share


2 answers


Double check your Web.config. I had the same problem until I realized I forgot to register the module.

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

      



I found this article on dotnetslackers helpful.

+5


source


Since Elmah is open source, you should add the code as a project to your solution and make sure you have a visual studio on all exceptions. It's clear that Elma throws an Exception that will swallow. This exact thing was happening to me and it was permission to the stored procedure that is inserting the error.

ORIGINAL
Is your test in a try / catch block? If so, you will have to explicitly force the registration.

Elmah.ErrorSignal.FromCurrentContext().Raise(ex);

      



SETTING UP MY WEB.CONFIG

  <configSections>
    <sectionGroup name="elmah">
      <section name="security" type="Elmah.SecuritySectionHandler, Elmah"/>
      <section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
    </sectionGroup>
   ...
   </configSections>

  <elmah>
    <security allowRemoteAccess="0" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="TESTElmahConnectionString" />
    <errorFilter>
      <test>
        <equal binding="HttpStatusCode" value="404" type="Int32" />
      </test>
    </errorFilter>
  </elmah>


<httpModules>
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <remove name="ScriptModule"/>
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated"/>
      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </handlers>
  </system.webServer>

      

+2


source







All Articles