You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2005/01/26 21:06:53 UTC

[NEW] Log4j Boolean Expression Language (LBEL)

Hello all,

Having just finished testing the first implementation of a boolean
expression language for logging events, I'd like to explain its
salient features.

LBEL allows the user to write arbitrarily complex boolean expressions
relative to logging events. For example,

(level >= INFO AND method = 'foo') OR (logger CHILDOF 'some.package')

In other words, LBEL is a classical boolean expression language where
OR, AND, NOT and parentheses carry their usual precedence and meaning.
However, LBEL supports several sub-expressions and keywords specific
to the evaluation of logging events.

The implementation is designed to short-circuit the evaluation of the
right side of 'AND' and 'OR' expressions resulting in tremendous
performance gains in some cases. For example, if 'left-side' is true,
LBEL will skip the evaluation of the right side in the following
expression.

   (left-side) OR (right-side).

Similarly, if left-side is false, the right-side will not be evaluated
for AND expressions.

More formally, here is the grammar for LBEL

<bexp> ::= <bexp> 'OR' <bterm>
<bexp> ::= <bterm>
<bterm> ::= <bterm> 'AND' <bfactor>
<bterm> ::= <bfactor>
<bfactor> ::= NOT <bfactor>
<bfactor> ::= '(' <bexp> ')'
<bfactor> ::= 'level' <numerical_op> 'DEBUG'|'INFO'|'WARN'|'ERROR'
<bfactor> ::= 'message' <string_op> <litteral>
<bfactor> ::= 'logger' <string_op> <litteral>
<bfactor> ::= 'logger' 'CHILDOF' <litteral>
<bfactor> ::= 'timestamp' <numerical_op> <NUMBER>
<bfactor> ::= many other sub-expression could be easily added
<numerical_op> ::= '=' | '!=' | '>' | '>=' | '<' | '<='
<string_op> ::= '=' | '!=' | '>' | '>=' | '<' | '<=' | '~' | '!~'

'~' and '!~' designate regular expression macthing.

The usual grammar transformation techniques have been applied to put
the above grammar in LL(1) form so that it could be parsed top-down.

Most of the difficult parts of the implementation are done and
tested. If there are no objections, I will commit them shortly.


-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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


Re: [NEW] Log4j Boolean Expression Language (LBEL)

Posted by Jacob Kjome <ho...@visi.com>.
Is this a generally useful package or specific to Log4j?  Does it directly
depend on Log4j?  If not, this could be a case where it might be a separate
jar, except for the all-encompassing logj4-all.jar which might include this (we
are going to distribute log4j-all.jar, whatever its name is chosen to be,
right?).  Similarily, it always seemed to me that Joran could be a separate
package to be used as an alternative to digester without respect to logging.  
However, I seem to recall you saying that there were Log4j internal
dependencies in Joran.  I'm not sure why that should be so I'm posing the
question; does Joran core really depend on Log4j?  I just think that being able
to separate these things from Log4j core would be a good thing to do and reduce
the bulk of the core log4j.jar, for instance in the case that someone is using
the PropertyConfigurator instead of the JoranConfigurator and doesn't need
LBEL.


Jake

Quoting Ceki Gülcü <ce...@qos.ch>:

> Hello all,
>
> Having just finished testing the first implementation of a boolean
> expression language for logging events, I'd like to explain its
> salient features.
>
> LBEL allows the user to write arbitrarily complex boolean expressions
> relative to logging events. For example,
>
> (level >= INFO AND method = 'foo') OR (logger CHILDOF 'some.package')
>
> In other words, LBEL is a classical boolean expression language where
> OR, AND, NOT and parentheses carry their usual precedence and meaning.
> However, LBEL supports several sub-expressions and keywords specific
> to the evaluation of logging events.
>
> The implementation is designed to short-circuit the evaluation of the
> right side of 'AND' and 'OR' expressions resulting in tremendous
> performance gains in some cases. For example, if 'left-side' is true,
> LBEL will skip the evaluation of the right side in the following
> expression.
>
>    (left-side) OR (right-side).
>
> Similarly, if left-side is false, the right-side will not be evaluated
> for AND expressions.
>
> More formally, here is the grammar for LBEL
>
> <bexp> ::= <bexp> 'OR' <bterm>
> <bexp> ::= <bterm>
> <bterm> ::= <bterm> 'AND' <bfactor>
> <bterm> ::= <bfactor>
> <bfactor> ::= NOT <bfactor>
> <bfactor> ::= '(' <bexp> ')'
> <bfactor> ::= 'level' <numerical_op> 'DEBUG'|'INFO'|'WARN'|'ERROR'
> <bfactor> ::= 'message' <string_op> <litteral>
> <bfactor> ::= 'logger' <string_op> <litteral>
> <bfactor> ::= 'logger' 'CHILDOF' <litteral>
> <bfactor> ::= 'timestamp' <numerical_op> <NUMBER>
> <bfactor> ::= many other sub-expression could be easily added
> <numerical_op> ::= '=' | '!=' | '>' | '>=' | '<' | '<='
> <string_op> ::= '=' | '!=' | '>' | '>=' | '<' | '<=' | '~' | '!~'
>
> '~' and '!~' designate regular expression macthing.
>
> The usual grammar transformation techniques have been applied to put
> the above grammar in LL(1) form so that it could be parsed top-down.
>
> Most of the difficult parts of the implementation are done and
> tested. If there are no objections, I will commit them shortly.
>
>
> --
> Ceki Gülcü
>
>    The complete log4j manual: http://www.qos.ch/log4j/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>




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