Asp.net
SQL Server 中的 ELMAH 日誌記錄
我遇到了 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>
你的配置看起來不錯。我有同樣的問題,它沒有記錄。我必須使用用於連接數據庫的憑據在 Elmah 儲存過程上添加執行權限。