Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop elmah from using the email handler for local requests?

Tags:

elmah

Can anyone suggest a quick way to tell Elmah not to use the email handler for local requests?

i.e. when Request.IsLocal == true I don't want to receive an email every time I generate an exception. Alternatively, a way to simply disable elmah altogether for local requests would be good.

I'd prefer an answer that doesn't require that I use a different Web.config locally than I use in production.

like image 312
Nathan Ridley Avatar asked Mar 12 '11 13:03

Nathan Ridley


1 Answers

You can configure error filtering in ELMAH and express conditions for when an exception should be filtered/excluded from logging and/or mailing. The following error filter should help you to filter out exceptions (as far as ELMAH is concerned) occurring on local requests:

<errorFilter>
    <test>
        <equal binding="Context.Request.IsLocal" 
               value="True" type="Boolean" />
    </test>
</errorFilter> 

For more details, see the wiki on Error Filtering and examples on the ELMAH project site.

like image 161
Atif Aziz Avatar answered Sep 28 '22 01:09

Atif Aziz