tags:

views:

294

answers:

3

Hello,

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 email report to the allowed users. How can i accomplish this feat?

Thank you,

Sean

A: 

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.

Jim Lamb
I'm not aware of a way to disable ELMAH from code-behind. You can, however, use configuration-specific web.config files to turn it off (or just use a different type of logging) in your development environment. See ScottGu's post here: http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx
Jim Lamb
A: 

Thanks Jim. can i do it with code behind? like:

if DEBUG

// disable elmah

else

// enable elmah

endif

Sean N
A: 

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

}
Eric King