加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – ELMAH日志如何按类型忽略错误

发布时间:2020-12-15 22:57:32 所属栏目:asp.Net 来源:网络整理
导读:你好,我在我的项目中设置了ELMAH,但是我遇到了很多错误 System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (:). Generated: Sun,26 May 2013 21:46:30 GMT System.Web.HttpException (0x80004005): A pot
你好,我在我的项目中设置了ELMAH,但是我遇到了很多错误

System.Web.HttpException: A potentially dangerous Request.Path value
was detected from the client (:).

Generated: Sun,26 May 2013 21:46:30 GMT

System.Web.HttpException (0x80004005): A potentially dangerous
Request.Path value was detected from the client (:). at
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at
System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext
context)

我想忽略它们,不要发送到我的邮件,但写入ELMAH DB.
有可能吗?

解决方法

是的,您可以使用ELMAH中的 error filtering,哪个是 described in detail on the project wiki.总之,web.config中的以下过滤器应该执行此操作(假设您已经设置了模块配置部分):
<errorFilter>
    <test>
        <and>
            <regex binding="FilterSourceType.Name" pattern="mail" />
            <regex binding="Exception.Message" 
               pattern="(?ix: b potentially b.+?b dangerous b.+?b value b.+?b detected b.+?b client b )" />
        </and>
    </test>
</errorFilter>

第一个<正则表达式>条件filters based on the filtering source,使邮寄不会发生. Check out the documentation on the wiki for full details.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读