You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Dasgupta, Ranjan" <Ra...@dell.com> on 2011/05/09 23:55:56 UTC

LikeRule in Apache Extras Companion (used by ExpressionFilter)

In the LikeRule evaluate(...) method, the matcher uses the matcher.matches(...) which checks for the whole string to match to. Shouldn't it be using the matcher.find(), so that we do not log if a part of the log string matched the pattern provided? Or is there any other way of doing that?
I am trying not to log messages that match \\b\\d{13,16}\\b

                        <filter class="org.apache.log4j.filter.ExpressionFilter">
                                <param name="Expression" value="MSG LIKE \\b\\d{13,16}\\b"/>
                                <param name="AcceptOnMatch" value="false"/>
                        </filter>
Thanks,
Ranjan Dasgupta




RE: LikeRule in Apache Extras Companion (used by ExpressionFilter)

Posted by "Dasgupta, Ranjan" <Ra...@dell.com>.
Scott, thanks for the quick reply. After looking at your example, I ended up with something like:
MSG LIKE .*\\b\\d{13,16}.*

Appreciate your help.

Regards,
Ranjan Dasgupta

-----Original Message-----
From: Scott Deboy [mailto:scott.deboy@gmail.com] 
Sent: Tuesday, May 10, 2011 1:32 AM
To: Log4J Users List
Subject: Re: LikeRule in Apache Extras Companion (used by ExpressionFilter)

I tried this in Chainsaw and it worked fine...note the single quotes and
adding .* before and after the expression..single quotes probably aren't
necessary unless you have spaces in your regexp..one other thing: I'm not
escaping the slashes since you don't have to escape them in Chainsaw.

msg like '.*\b\(\d{3}\)\s.*'

matches this entry:
743 - 2011/04/27 14:23:57 -  - DEBUG - Unknown - 20110427 14:25:38.605
ERROR    RI.TEST- testAppThread accept(316) failed? -  - AWT-EventQueue-0

Scott

On Mon, May 9, 2011 at 2:55 PM, Dasgupta, Ranjan
<Ra...@dell.com>wrote:

> In the LikeRule evaluate(...) method, the matcher uses the
> matcher.matches(...) which checks for the whole string to match to.
> Shouldn't it be using the matcher.find(), so that we do not log if a part of
> the log string matched the pattern provided? Or is there any other way of
> doing that?
> I am trying not to log messages that match \\b\\d{13,16}\\b
>
>                        <filter
> class="org.apache.log4j.filter.ExpressionFilter">
>                                <param name="Expression" value="MSG LIKE
> \\b\\d{13,16}\\b"/>
>                                <param name="AcceptOnMatch" value="false"/>
>                        </filter>
> Thanks,
> Ranjan Dasgupta
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: LikeRule in Apache Extras Companion (used by ExpressionFilter)

Posted by Scott Deboy <sc...@gmail.com>.
I tried this in Chainsaw and it worked fine...note the single quotes and
adding .* before and after the expression..single quotes probably aren't
necessary unless you have spaces in your regexp..one other thing: I'm not
escaping the slashes since you don't have to escape them in Chainsaw.

msg like '.*\b\(\d{3}\)\s.*'

matches this entry:
743 - 2011/04/27 14:23:57 -  - DEBUG - Unknown - 20110427 14:25:38.605
ERROR    RI.TEST- testAppThread accept(316) failed? -  - AWT-EventQueue-0

Scott

On Mon, May 9, 2011 at 2:55 PM, Dasgupta, Ranjan
<Ra...@dell.com>wrote:

> In the LikeRule evaluate(...) method, the matcher uses the
> matcher.matches(...) which checks for the whole string to match to.
> Shouldn't it be using the matcher.find(), so that we do not log if a part of
> the log string matched the pattern provided? Or is there any other way of
> doing that?
> I am trying not to log messages that match \\b\\d{13,16}\\b
>
>                        <filter
> class="org.apache.log4j.filter.ExpressionFilter">
>                                <param name="Expression" value="MSG LIKE
> \\b\\d{13,16}\\b"/>
>                                <param name="AcceptOnMatch" value="false"/>
>                        </filter>
> Thanks,
> Ranjan Dasgupta
>
>
>
>