Reputation: 81
I am using ELMAH for error reporting in my ASP.NET projects. Everything is working great, except when I debug a project I don't want to send an email report to the allowed users. How can I accomplish this feat?
Upvotes: 8
Views: 8605
Reputation: 73
Another way is to use the ErrorMail_Mailing method. When ELMAH sends the email, it runs this first (when present in global.asax.cs)
public void ErrorMail_Mailing(object sender, ErrorMailEventArgs e)
{
#if DEBUG
e.Mail.To.Clear();
e.Mail.To.Add("[email protected]");
e.Mail.Subject = "Error in Development";
#endif
}
The example above can be via the the transformations in web.Debug.config & web.Release.config. But there is a lot more you can do in this method. See http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx
Upvotes: 0
Reputation: 11744
Maybe you can use ErrorFiltering to turn off the email logging in the Global.asax. Something like:
void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e)
{
#if DEBUG
e.Dismiss();
#endif
}
Upvotes: 6
Reputation: 25775
Assuming you have different web.config files for your development and production environments, just disable Elmah in your development web.config. You'll want to comment out (or remove) the Elmah.ErrorLogModule element in the httpModules section.
Upvotes: 8