Filter not to log certain exception type

233 views
Skip to first unread message

Hardy

unread,
Apr 30, 2012, 1:28:51 PM4/30/12
to el...@googlegroups.com
Can I do it in Elmah and not to log certain exception types?

Atif Aziz

unread,
Apr 30, 2012, 2:08:23 PM4/30/12
to el...@googlegroups.com
Yes, see these resources:

- Atif

 
On Mon, Apr 30, 2012 at 7:28 PM, Hardy <hardy.y...@gmail.com> wrote:
Can I do it in Elmah and not to log certain exception types?

--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To view this discussion on the web visit https://groups.google.com/d/msg/elmah/-/pXUdwGxMz_0J.
To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elmah?hl=en.

Hardy

unread,
May 1, 2012, 9:57:08 AM5/1/12
to el...@googlegroups.com
You have provided very good samples, but I did not find comprehensive document to describe how to use each filter type or configure element.

For example I want to skip logging all exception type System.Net.Sockets.SocketException, I tried following configuration in my web.config but it does not seem to work at all.

    <errorFilter>
      <test>
        <jscript>
          <expression><![CDATA[
// @import System.Net

BaseException instanceof System.Net.Sockets.SocketException
]]></expression>
        </jscript>
      </test>
    </errorFilter>

On Monday, 30 April 2012 14:08:23 UTC-4, Atif Aziz wrote:
Yes, see these resources:

- Atif

 
On Mon, Apr 30, 2012 at 7:28 PM, Hardy <hardy.y...@gmail.com> wrote:
Can I do it in Elmah and not to log certain exception types?

--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To view this discussion on the web visit https://groups.google.com/d/msg/elmah/-/pXUdwGxMz_0J.
To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+unsubscribe@googlegroups.com.

Atif Aziz

unread,
May 1, 2012, 11:25:23 AM5/1/12
to el...@googlegroups.com
Try instead like this and see if it helps:

<errorFilter>
  <test>
    <jscript>
      <expression><![CDATA[
                // @assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                // @import System.Net

                $.BaseException instanceof System.Net.Sockets.SocketException
                ]]></expression>
    </jscript>
  </test>
</errorFilter>

I've also posted it online at: https://gist.github.com/2568751

I've essentially added the assembly reference (you might need to change the version number if you're not on .NET Framework 4.0) and a qualified BaseException with a dollar ($). See issue #278 that was fixed in ELMAH 1.2 SP 2 for background on why the dollar qualification is needed. If you not upgraded to ELMAH 1.2 SP 2 yet then you can use the undocumented $context instead as described in the sample web.config shipped with ELMAH 1.2 SP2.

- Atif

To view this discussion on the web visit https://groups.google.com/d/msg/elmah/-/nvZ7Eo0XqGgJ.

To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+un...@googlegroups.com.

Hardy

unread,
May 1, 2012, 1:38:31 PM5/1/12
to el...@googlegroups.com
I tried, it does not seem to block the logging of such exception.

Atif Aziz

unread,
May 1, 2012, 1:58:32 PM5/1/12
to el...@googlegroups.com
Do you have the ErrorFilterModule registered after all other ELMAH modules?
Which version of ELMAH are you using?
Which version of ASP.NET are you using?
Are you in a dev environment? If yes, are you able to attach the debugger & see if the JScript assertion is tracing any diagnostics messages?

- Atif
To view this discussion on the web visit https://groups.google.com/d/msg/elmah/-/uDdttYOAczUJ.

To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages