加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – ELMAH适用于本地机器,但不适用于生产

发布时间:2020-12-16 00:00:05 所属栏目:百科 来源:网络整理
导读:设置简单,我使用ELMAH记录异常并向我发送电子邮件.在我的本地机器上一切正常,但是当我在生产服务器上进行更改时,错误不会被记录,我也没有收到电子邮件. 这是我本地机器上的web.config: ?xml version="1.0"?configuration configSections sectionGroup name=
设置简单,我使用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,HEAD" path="elmah.axd"
                    type="Elmah.ErrorLogPageFactory,Elmah" />
            </httpHandlers>
        </system.web>
    </location>
</configuration>

我机器上的web.config与生产之间的唯一区别是正在使用的连接字符串.在我的机器上,我正在连接到.mdf文件.在生产时,我正在连接到外部数据库.

谁能看到我在这里做错了什么?

我正在使用C#和ASP.NET MVC 3

解决方法

你在生产中运行IIS7吗?在这里阅读我对类似问题的回答 Elmah,convert to .Net4 vs2010,run on server 2008,does not work

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读