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 Mike Schilli <ms...@aol.com> on 2003/02/19 20:13:27 UTC

Future of Custom Filters?

Hi there,

... in the complete log4j manual, I found the following note:

    "In the next version of log4j, the set of available
filters will be widened and each individual filter retrofitted with the 
ability to
act on negative matches (mismatches) whereas currently shipped filters 
can only act
on positive matches."

That sounds interesting, do you guys have a spec for this yet? I'd like 
to take a peek if possible. Also, is the following going to change?

    "Up to and including log4j version 1.2, filters can only added to 
Appender instances."

This sounds like there's planning in progress, too -- would be great if 
you could send out pointers as well.

BTW, in the log4perl world, we're thinking about having the following: A 
special custom filter called "Bool" that comes with the distribution and 
lets you combine other custom filters. Check this out:

    log4perl.filter.Match1       = ...
    log4perl.filter.Match2       = ...
    log4perl.filter.MyBool       = Log::Log4perl::Filter::Bool
    log4perl.filter.MyBool.logic = Match1 || Match2

    log4perl.appender.Screen        = Log::Dispatch::Screen
    log4perl.appender.Screen.Filter = MyBool

This way, MyBool will let a message through if either the Match1 or 
Match2 custom filter allow the message to pass (&& and ! and parentheses 
are also supported for the whole Boolean Algebra set) . Also, we're 
planning on allowing to specify custom filters in the 
Property-Configurator as well -- did you guys have a special reason as 
why to only provide it in XML? XML's so hard to read for humans, we find 
the Property-format easier to comprehend and maintain.

Sorry, about so many questions, but I hope this is of interest to the 
log4j community, too ... thanks for your time!

-- 
-- Mike

Mike Schilli
log4perl@perlmeister.com
http://log4perl.sourceforge.net




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


Re: Future of Custom Filters?

Posted by Ceki Gülcü <ce...@qos.ch>.
By the way, you can find the o.a.l.filters directory in the log4j-sandbox 
instead of log4j proper. Mark, I think they should be moved back to the 
main log4j branch.

At 06:58 AM 2/28/2003 +0100, you wrote:
>Hi Mike,
>
>Sorry for not responding earlier. Comments inline.
>
>At 11:13 AM 2/19/2003 -0800, Mike Schilli wrote:
>>Hi there,
>>
>>... in the complete log4j manual, I found the following note:
>>
>>    "In the next version of log4j, the set of available
>>filters will be widened and each individual filter retrofitted with the 
>>ability to
>>act on negative matches (mismatches) whereas currently shipped filters 
>>can only act
>>on positive matches."
>>
>>That sounds interesting, do you guys have a spec for this yet? I'd like 
>>to take a peek if possible. Also, is the following going to change?
>
>We don't have a formal spec although the existing documentation especially 
>in the book pretty much "specifies" generic filters. Custom filters are 
>based on ternary logic. See the o.a.l.spi.Filter class for more details.
>
>This principle of ternary logic remains exactly the same in 1.3. However, 
>Mark Womack enhanced the existing Filter *implementations* to respond to 
>negative matches as well as to positive matches whereas previously only 
>positive matches were considered.
>
>>    "Up to and including log4j version 1.2, filters can only added to 
>> Appender instances."
>
>One possibility is to have filters attached to loggers as well. The 
>implementation is trivial and can be done probably in 60 seconds. The real 
>question is the meaning of filters with respect to the logger hierarchy, 
>that is how are filters inherited or composed? For example, if you have 
>filters in the root logger as well as in logger "a.b", what filters should 
>one use when logging with "a.b.c"?
>
>I had a satisfactory answer to this question but can't remember it now. 
>Ah, those memory cells...
>
>>This sounds like there's planning in progress, too -- would be great if 
>>you could send out pointers as well.
>>
>>BTW, in the log4perl world, we're thinking about having the following: A 
>>special custom filter called "Bool" that comes with the distribution and 
>>lets you combine other custom filters. Check this out:
>>
>>    log4perl.filter.Match1       = ...
>>    log4perl.filter.Match2       = ...
>>    log4perl.filter.MyBool       = Log::Log4perl::Filter::Bool
>>    log4perl.filter.MyBool.logic = Match1 || Match2
>>
>>    log4perl.appender.Screen        = Log::Dispatch::Screen
>>    log4perl.appender.Screen.Filter = MyBool
>>
>>This way, MyBool will let a message through if either the Match1 or 
>>Match2 custom filter allow the message to pass (&& and ! and parentheses 
>>are also supported for the whole Boolean Algebra set) .
>
>That is binary logic. Although it is more familiar, binary logic is less 
>suitable than ternary logic in this particular case of filter chains.
>
>>Also, we're planning on allowing to specify custom filters in the 
>>Property-Configurator as well -- did you guys have a special reason as 
>>why to only provide it in XML? XML's so hard to read for humans, we find 
>>the Property-format easier to comprehend and maintain.
>
>Well, the order in which filters are listed in a config file is 
>crucial.  The java.util.Properties class does not guarantee that the 
>enumeration of properties matches the order in which they appear in a 
>config file. Without that guarantee filters chains do not make much sense.
>
>You can do really cool (and useful) things in XML that are simply not 
>possible or very awkward in key=value format. This is going to be 
>especially evident once the DOMConfigurator is enhanced to learn new 
>parsing rules on the fly. BTW, it can deal with arbitrary nested elements 
>TODAY. (I'll write something about this when I get a chance.)
>
>>Sorry, about so many questions, but I hope this is of interest to the 
>>log4j community, too ... thanks for your time!
>
>Certainly is.
>
>>--
>>-- Mike
>>
>>Mike Schilli
>>log4perl@perlmeister.com
>>http://log4perl.sourceforge.net
>
>--
>Ceki
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

--
Ceki 


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


Re: Future of Custom Filters?

Posted by Ceki Gülcü <ce...@qos.ch>.
Hi Mike,

Sorry for not responding earlier. Comments inline.

At 11:13 AM 2/19/2003 -0800, Mike Schilli wrote:
>Hi there,
>
>... in the complete log4j manual, I found the following note:
>
>    "In the next version of log4j, the set of available
>filters will be widened and each individual filter retrofitted with the 
>ability to
>act on negative matches (mismatches) whereas currently shipped filters can 
>only act
>on positive matches."
>
>That sounds interesting, do you guys have a spec for this yet? I'd like to 
>take a peek if possible. Also, is the following going to change?

We don't have a formal spec although the existing documentation especially 
in the book pretty much "specifies" generic filters. Custom filters are 
based on ternary logic. See the o.a.l.spi.Filter class for more details.

This principle of ternary logic remains exactly the same in 1.3. However, 
Mark Womack enhanced the existing Filter *implementations* to respond to 
negative matches as well as to positive matches whereas previously only 
positive matches were considered.

>    "Up to and including log4j version 1.2, filters can only added to 
> Appender instances."

One possibility is to have filters attached to loggers as well. The 
implementation is trivial and can be done probably in 60 seconds. The real 
question is the meaning of filters with respect to the logger hierarchy, 
that is how are filters inherited or composed? For example, if you have 
filters in the root logger as well as in logger "a.b", what filters should 
one use when logging with "a.b.c"?

I had a satisfactory answer to this question but can't remember it now. Ah, 
those memory cells...

>This sounds like there's planning in progress, too -- would be great if 
>you could send out pointers as well.
>
>BTW, in the log4perl world, we're thinking about having the following: A 
>special custom filter called "Bool" that comes with the distribution and 
>lets you combine other custom filters. Check this out:
>
>    log4perl.filter.Match1       = ...
>    log4perl.filter.Match2       = ...
>    log4perl.filter.MyBool       = Log::Log4perl::Filter::Bool
>    log4perl.filter.MyBool.logic = Match1 || Match2
>
>    log4perl.appender.Screen        = Log::Dispatch::Screen
>    log4perl.appender.Screen.Filter = MyBool
>
>This way, MyBool will let a message through if either the Match1 or Match2 
>custom filter allow the message to pass (&& and ! and parentheses are also 
>supported for the whole Boolean Algebra set) .

That is binary logic. Although it is more familiar, binary logic is less 
suitable than ternary logic in this particular case of filter chains.

>Also, we're planning on allowing to specify custom filters in the 
>Property-Configurator as well -- did you guys have a special reason as why 
>to only provide it in XML? XML's so hard to read for humans, we find the 
>Property-format easier to comprehend and maintain.

Well, the order in which filters are listed in a config file is 
crucial.  The java.util.Properties class does not guarantee that the 
enumeration of properties matches the order in which they appear in a 
config file. Without that guarantee filters chains do not make much sense.

You can do really cool (and useful) things in XML that are simply not 
possible or very awkward in key=value format. This is going to be 
especially evident once the DOMConfigurator is enhanced to learn new 
parsing rules on the fly. BTW, it can deal with arbitrary nested elements 
TODAY. (I'll write something about this when I get a chance.)

>Sorry, about so many questions, but I hope this is of interest to the 
>log4j community, too ... thanks for your time!

Certainly is.

>--
>-- Mike
>
>Mike Schilli
>log4perl@perlmeister.com
>http://log4perl.sourceforge.net

--
Ceki 


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