簡單設置,我使用ELMAH記錄異常並向我發送電子郵件。在我的本地機器上一切正常,但是當我將這些更改放到生產服務器上時,錯誤不會被記錄下來,也不會收到電子郵件。ELMAH在本地機器上工作,但不在生產上
這是我在我的本地機器上的web.config:
<?xml version="1.0"?>
<configuration>
<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" />
</sectionGroup>
</configSections>
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="MyDB" />
<errorMail from="[email protected]" to="[email protected]"
subject="Error" smtpServer="localhost" smtpPort="25"
userName="[email protected]" password="mypassword" />
</elmah>
<connectionStrings>
<add name="MyDB" connectionString="Data Source=.\SQLEXPRESS
AttachDbFilename=|DataDirectory|\MyDB.mdf;
Integrated Security=True;User Instance=True;
MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
<!--<add name="MyDB" connectionString="Server=mysite.com;
Database=MyDB;User ID=user;Password=mypassword;
Trusted_Connection=True;Integrated Security=False;
MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />-->
</connectionStrings>
<system.web>
<!--<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>-->
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
</system.web>
<location path="Admin/Errors">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
</location>
</configuration>
我的機器上,並在生產中的web.config之間唯一的區別是使用的連接字符串。在我的機器上,我連接到一個.mdf文件。在生產中,我連接到外部數據庫。
任何人都可以看到我在做什麼錯在這裏?
我使用C#和ASP.NET MVC 3
您的生產服務器運行的是哪個版本的IIS? – NotMe
此評論適用於可能有相同問題的其他人。不要忘記還要在生產服務器上創建3個存儲過程。 (ELMAH_GetErrorsXml,ELMAH_GetErrorXml和ELMAH_LogError,並且該訪問權限是爲數據庫用戶提供的)。希望這可以幫助某人。 – ProgrammerV5