I wanted to know if there is a way that I can write ELMAH to filter out error logging under the following logic:
If the error is a 404 on favicon.ico
OR the error is 404 on /1.xml
OR the error is 404 on /2.xml
I have found the way to just do it on the favicon.ico
as shown:
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<regex binding="Context.Request.ServerVariables['URL']" pattern="/favicon\.ico(\z|\?)" />
</and>
</test>
</errorFilter>
But for some reason, I cannot understand how to do it for the OR
conditions. Any help will be much appreci开发者_如何学运维ated.
The following should do the trick or otherwise get you started:
<errorFilter>
<test>
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<or>
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/favicon\.ico(\z|\?)" />
<regex binding="Context.Request.ServerVariables['URL']"
pattern="/[1-2]\.xml(\z|\?)" />
</or>
</and>
</test>
</errorFilter>
Basically, this will filter errors where the HTTP status code is 404 and one of the regular expressions patterns grouped under the or
element match the request URL.
精彩评论