我对以下 web.config 设置和 Elmah 有疑问。问题是,当我不愿意时,我仍然会收到有关公共行动方法问题的电子邮件。我安装的过滤器似乎不起作用。
我不完全确定 AND 和 OR 在 Elmah 电子邮件过滤中应该如何工作,特别是因为此代码是从我从其他开发人员那里获得的一些项目工作中剪下来的。
这些标签旨在防止通过电子邮件报告任何包含索引、缓存或登录字样的错误。
有人可以帮忙吗?
<configuration>
<configSections>
<!--Elmah sectionGroup-->
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
<errorMail from="" to="" subject="Error(Elmah)" async="true " />
<security allowRemoteAccess="1"/>
<errorFilter>
<test>
<or>
<is-type binding="BaseException" type="System.InvalidOperationException" />
</or>
<or>
<regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" />
</or>
<or>
<regex binding="Exception.Message" pattern="(?ix: \b public action method 'Index' was not found on controller \b )" />
<regex binding="Exception.Message" pattern="(?ix: \b public action method 'cache' was not found on controller \b )" />
<regex binding="Exception.Message" pattern="(?ix: \b public action method 'Login' was not found on controller \b )" />
</or>
</test>
</errorFilter>
</elmah>
<location path="elmah.axd">
</location>
<system.web>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</modules>
<handlers>
<add name="httpHandler" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
</system.webServer>
</configuration>
The test
元素只能有一个子断言,因此有多个or
它下面的元素意味着除了第一个之外的所有元素都将被忽略。从你的描述来看,你的test
元素应该这样读:
<test>
<or>
<is-type binding="BaseException" type="System.InvalidOperationException" />
<regex binding="Exception.Message" pattern="(?ix: \b potentially \b.+?\b dangerous \b.+?\b value \b.+?\b detected \b.+?\b client \b )" />
<and>
<regex binding="FilterSourceType.Name" pattern="mail" />
<regex binding="Exception.Message" pattern="(?ix: \b public \s action \s method \s '(Index|cache|Login)' \s was \s not \s found \s on \s controller \b )" />
</and>
</or>
</test>
请注意,我还继续折叠了三个regex
元素合二为一并修复模式以正确分隔单词(\b
在边缘和\s
之间)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)