Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELMAH Logging in SQL Server

I am having an ELMAH problem. I think it is the connection string but can't figure out why. It is emailing me errors no problem, just not logging them into sql. If the problem is permissions, how would I catch an error to show me its a permission problem? Here are the elmah relevant section of my web.config:

<configSections>
<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" />
  <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" />
</sectionGroup>

<connectionStrings>
<add name="ErrorLog" connectionString="Data Source=SQL1;Initial Catalog=ASBESTOS;User Id=MyUserName;Password=MyPassword" providerName="System.Data.SqlClient" />    

<system.web>
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />

<elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ErrorLog"/>    
    <errorMail from="[email protected]" to="[email protected]" subject="Asbestos Error Log" async="true"></errorMail>
  </elmah>
  <location path="elmah.axd" inheritInChildApplications="false">
  <system.web>
      <authorization>
        <allow roles="System" />
        <deny users="*" />
      </authorization>
      <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>
like image 781
Ethan Schofer Avatar asked May 02 '13 14:05

Ethan Schofer


1 Answers

Your config looks good. I had the same issue where it wasn't logging. I had to add execute permissions on the Elmah stored procs with the credentials I was using to connect to the DB.

like image 87
Beanwah Avatar answered Nov 14 '22 16:11

Beanwah