【发布时间】:2010-05-31 08:34:08
【问题描述】:
我为 Web 应用设置了 ELMAH,将异常记录到 SQL 服务器。
我也希望 ELMAH 给我发一封电子邮件,但仅限于抛出特定异常时(即。MySpecialException)。
ELMAH 仍必须将所有异常记录到 SQL 服务器。
我知道您可以在 global.asax 中以编程方式执行此操作,但我更喜欢使用 web.config。
那么,如何使用 web.config 限制 ELMAH 错误邮件以过滤除特定异常类型之外的所有内容?
更新
过滤器最终看起来像这样:
<test>
<and>
<not>
<is-type binding="Exception" type="MyApp.MySpecialException" />
</not>
<regex binding="FilterSourceType.Name" pattern="mail" caseSensitive="false"/>
</and>
</test>
【问题讨论】: