简单设置,我使用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="errors@mysite.com" to="myemail@mysite.com"
subject="Error" smtpServer="localhost" smtpPort="25"
userName="user@mysite.com" 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
答案 0 :(得分:9)
您需要为远程访问设置allowRemoteAccess =“yes”。
<elmah>
<security allowRemoteAccess="yes"/>
</elmah>
并查看elmah管理页面,看看是否对您有帮助。
答案 1 :(得分:3)
您是否在生产中运行IIS7?请在此处阅读我对类似问题的回答Elmah, convert to .Net4 vs2010, run on server 2008, does not work