开发者

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

开发者 https://www.devze.com 2023-02-16 05:06 出处:网络
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 gener开发者_开发技巧ate

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 gener开发者_开发技巧ate 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消