سؤال

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. 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.

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.

Basically all I have so far is this ELMAH email setting:

<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:

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:

<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.

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 :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top