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.
精彩评论