Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter on exception text in elmah

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!

like image 633
kcode Avatar asked Dec 03 '22 06:12

kcode


1 Answers

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>
like image 137
Drew Freyling Avatar answered Mar 20 '23 09:03

Drew Freyling