嘿我使用Elmah來記錄我的MVC剃鬚刀錯誤,我使用SMTP電子郵件配置通過電子郵件得到通知,問題是,elma發送電子郵件扔我本地調試,我不想要它,因爲我只想在觸發器只在生產服務器i上記錄錯誤,我該怎麼做。我想Elmah只是發送生產服務器上的日誌錯誤iis
我知道我可以刪除web.config中的smtp行,但我做了很多更改,我希望它具有動態性。 感謝
嘿我使用Elmah來記錄我的MVC剃鬚刀錯誤,我使用SMTP電子郵件配置通過電子郵件得到通知,問題是,elma發送電子郵件扔我本地調試,我不想要它,因爲我只想在觸發器只在生產服務器i上記錄錯誤,我該怎麼做。我想Elmah只是發送生產服務器上的日誌錯誤iis
我知道我可以刪除web.config中的smtp行,但我做了很多更改,我希望它具有動態性。 感謝
看看答案從這個頁面:
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.
隨着web.config中變換:
這在你的web.production.config,用正確的參數
<errorMail from="[email protected]" to="[email protected]" cc="[email protected]" subject="CDF 54 ELMAH Error" async="true" smtpPort="587" useSsl="true" smtpServer="smtp.gmail.com" userName="[email protected]" password="YOURPASS" xdt:Transform="Insert" /> </elmah>
試試這個。
<errorMail xdt:Transform="InsertAfter(/configuration/elmah)"
from="[email protected]"
to="[email protected]"
subject="..."
/>
是的,但它引發了這個異常:命名空間前綴'xdt'未定義web.config我試圖獲取命名空間,但我無法找到它 – user2979690