我让ELMAH设置了webapp,将异常记录到SQL服务器.
我希望ELMAH也向我发送电子邮件,但仅在抛出特定异常时(即MySpecialException).
ELMAH仍必须记录SQL Server的所有异常.
我知道你可以在global.asax中以编程方式进行,但我更喜欢使用web.config.
那么,如何使用web.config限制ELMAH错误邮件以过滤掉除特定异常类型之外的所有内容?
UPDATE
过滤器最终看起来像这样:
<test>
<and>
<not>
<is-type binding="Exception" type="MyApp.MySpecialException" />
</not>
<regex binding="FilterSourceType.Name" pattern="mail" caseSensitive="false"/>
</and>
</test>
Run Code Online (Sandbox Code Playgroud)
它当然可以做到.查看elmah的过滤文档.
特别请查看按源过滤部分
<elmah>
...
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
</test>
</errorFilter>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2607 次 |
最近记录: |