过滤elmah中的异常文本 [英] Filter on exception text in elmah
问题描述
示例:
System.Web.HttpException:请求定时去。我不想过滤掉所有HttpException,而只是过滤出超时请求。
System.Web.HttpException:超出最大请求长度。
我不想做的是编写自己的代码。那么可以用buildin-web.config配置来实现吗?
谢谢!
是的,你可以。只需使用正则表达式来询问消息。有关如何比较异常消息的详细信息,请参阅下面的示例。
< errorFilter>
< test>
<! - http://groups.google.com/group/elmah/t/cbe82cee76cc6321 - >
<和>
< is-type binding ='Exception'
type ='System.Web.HttpException,System.Web,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'/>
< regex binding ='Exception.Message'
pattern ='invalid\s + viewstate'
caseSensitive ='false'/>
< regex binding ='Context.Request.UserAgent'
pattern ='Trident / 4(\。[0-9])*'
caseSensitive ='false'/>
< /和>
< / test>
< / errorFilter>
Is there a way to filter exceptions in elma using the exception message?
Examples:
"System.Web.HttpException: Request timed out." I don't want to filter out all HttpException, but only the timed-out requests.
"System.Web.HttpException: Maximum request length exceeded."
What I don't want to do is write own code for that. So is it possible to do this with the buildin-web.config configuration?
Thank you!
Yes you can. Just use a regular expression to interrogate the message. See the example below for details on how to compare the exception message.
<errorFilter>
<test>
<!-- http://groups.google.com/group/elmah/t/cbe82cee76cc6321 -->
<and>
<is-type binding='Exception'
type='System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' />
<regex binding='Exception.Message'
pattern='invalid\s+viewstate'
caseSensitive='false' />
<regex binding='Context.Request.UserAgent'
pattern='Trident/4(\.[0-9])*'
caseSensitive='false' />
</and>
</test>
</errorFilter>
这篇关于过滤elmah中的异常文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!