简体   繁体   English

在本地开发时(使用Elmah)向该特定用户发送错误电子邮件?

[英]Send error emails to that specific user when developing locally (using Elmah)?

I'm using Elmah and what I would like to happen is that when one of our multiple developers is running their project locally, they only receive any error emails generated from that local instance, if the error is generated on the live server, email a different (group) email. 我正在使用Elmah,我想要发生的是当我们的多个开发人员之一在本地运行他们的项目时,他们只接收从该本地实例生成的任何错误电子邮件,如果在实时服务器上生成错误,则发送电子邮件不同的(群组)电子邮件。 Right now we are just using the (horrible) method of each person having their own web.config that shouldn't (but sometimes does) get committed to our Repo, and then changing the email string when deploying to live. 现在我们只是使用每个人拥有自己的web.config的(可怕)方法,不应该(但有时会)提交到我们的Repo,然后在部署到live时更改电子邮件字符串。

We are all using VS 2010 and Cassini, but the developers could be working from their work computer or their home computer where they connect through VPN, but their login name on their home computer doesn't reflect their work computer username. 我们都在使用VS 2010和Cassini,但是开发人员可以通过他们的工作计算机或他们通过VPN连接的家用计算机工作,但他们在家用计算机上的登录名并不反映他们的工作计算机用户名。

Basically all I have so far is this ELMAH email setting: 基本上我到目前为止所有的ELMAH电子邮件设置:

<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahDb" />
<errorMail from="no-reply@mydomain.com" to="myemail@mydomain.com" subject="Project Error" smtpPort="0" async="false" />

And an empty method in Application_Start: Application_Start中的空方法:

protected void Application_Start()
    {
        Config.SetErrorEmailReceiver();
    }

public static void SetErrorEmailReceiver()
    {
        //some logic
    }

The best approach is probably to use an external config file. 最好的方法可能是使用外部配置文件。 So, you would change your web.config to say: 所以,你会改变你的web.config来说:

<errorMail configSource="elmah-errorMail.config" /> 

And then each developer would have their own copy of that file which would contain: 然后每个开发人员都有自己的文件副本,其中包含:

<errorMail from="no-reply@mydomain.com" to="myemail@mydomain.com" subject="Project Error" smtpPort="0" async="false" />

And then of course you also have the production values on your production web server. 当然,您还可以在生产Web服务器上获得生产值。

I still don't understand why you want emails sent out to the developer though. 我仍然不明白为什么你想要发送给开发者的电子邮件。 Isn't a yelllow screen of death enough of an alert :) 是不是死亡的yelllow屏幕足够的警报:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM