我希望Elmah只在生产服务器iis上发送日志错误

时间:2014-02-20 13:29:55

标签: c# asp.net-mvc-4 iis smtp elmah

嘿我使用Elmah记录我的MVC剃刀错误,我使用SMTP电子邮件配置通过电子邮件收到通知,问题是elma发送电子邮件抛出我的本地调试程序,我不想要它,因为我只是想仅在生产服务器iis上触发时才记录错误,我该怎么做。

我知道我可以在web.config中删除smtp行但是我做了很多更改,我想让它动态化。 感谢

3 个答案:

答案 0 :(得分:0)

看一下本页的答案:

ELMAH: Can you set it up to email errors only remotely?

I found a solution which is to use config transforms with VS 2010. I remove the tag from my base web.config then added it to my Web.Qa.Config and Web.Release.Config with transform tags. When I publish, it allows the remote machines to send out the emails while they are supressed locally. I will end up going this route, but I will let your answer get a few more upvotes and mark it as answer based on that.

答案 1 :(得分:0)

使用web.config转换:

这在你的web.production.config中,带有正确的参数

<errorMail from="tfscdf54@gmail.com"
                to="jose.alvarez54@free.fr"
                cc="cdf.bts.iris@live.fr"
                subject="CDF 54 ELMAH Error"
                async="true"
                smtpPort="587"
                useSsl="true"
                smtpServer="smtp.gmail.com"
                userName="tfscdf54@gmail.com"
                password="YOURPASS" xdt:Transform="Insert" />   </elmah>

答案 2 :(得分:0)

试试这个。

<errorMail  xdt:Transform="InsertAfter(/configuration/elmah)"
        from="from@test.com"
        to="to@test.com"
        subject="..."
        />
相关问题