【问题标题】:ELMAH Logging in SQL ServerSQL Server 中的 ELMAH 日志记录
【发布时间】:2013-05-02 14:00:03
【问题描述】:

我遇到了 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>

<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="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>

【问题讨论】:

    标签: asp.net sql-server web-config connection-string elmah


    【解决方案1】:

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

    【讨论】:

    • 呃。我是一个白痴。在项目进行到一半时,我切换到 Code First,并多次重建数据库,包括 ELMAH 表,这意味着表的权限发生了变化。因此,您关于权限的提示是正确的。谢谢。
    • 非常有帮助。仅供参考,添加执行权限的语法是:GRANT EXECUTE ON [StoredProcName] TO [UserName]
    猜你喜欢
    • 1970-01-01
    • 2014-10-16
    • 1970-01-01
    • 2010-10-23
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    • 2011-03-01
    相关资源
    最近更新 更多