ELMAH登录SQL Server

Eth*_*fer 16 sql-server asp.net connection-string elmah web-config

我有一个ELMAH问题.我认为这是连接字符串,但无法弄清楚原因.它通过电子邮件发送给我错误没问题,只是没有将它们记录到sql中.如果问题是权限,我如何捕获错误以向我显示其权限问题?以下是我的web.config的elmah相关部分:

<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>
Run Code Online (Sandbox Code Playgroud)

<connectionStrings>
<add name="ErrorLog" connectionString="Data Source=SQL1;Initial Catalog=ASBESTOS;User Id=MyUserName;Password=MyPassword" providerName="System.Data.SqlClient" />    
Run Code Online (Sandbox Code Playgroud)

<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" />
Run Code Online (Sandbox Code Playgroud)

<elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ErrorLog"/>    
    <errorMail from="support@asbestos.phmc.org" to="ethan@phmc.org" 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>
Run Code Online (Sandbox Code Playgroud)

Bea*_*wah 18

你的配置看起来不错.我有同样的问题,它没有记录.我必须使用我用来连接数据库的凭据在Elmah存储过程中添加执行权限.

  • 啊.我是一个白痴.在项目的中途,我切换到Code First,并多次重建数据库,包括ELMAH表,这意味着对表的权限发生了变化.所以,关于权限的提示是正确的.谢谢. (2认同)