You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2004/10/27 00:35:35 UTC

Re: [logging] bytecode engineering (was: Re: Commons Configuration - Digester Logging turned off)

On 26 Oct 2004, at 22:40, Simon Kitching wrote:

> On Tue, 2004-10-26 at 10:47, robert burrell donkin wrote:
>> this might be a bit left field but i've been turning over the idea for
>> some time of using byte code engineering to wire up logging. one of 
>> the
>> problems with commons-logging is that it's nearly impossible to be all
>> thing to all people. the idea of running an enhancer at at a jar to
>> turn off logging (complete), switch to micro-thin logger or a non-j2ee
>> one appeals to me.
>
> It does seem tempting from a performance point of view. I've always
> thought it a bit odd that log4j goes to great lengths to optimise
> performance, then commons-logging adds a layer of indirection on top
> which is executed for every log statement (including those which are
> filtered out). Modifying the bytecode to make direct calls to the
> selected logging library seems nicer.

from a performance perspective, i'm not convinced that the extra call 
layer should make much difference in practice. (highly optimized loops 
should not contain any logging statements.) i strongly suspect that the 
principle cost in commons-logging is the cost of getting a log from the 
factory.

i'd say that just hard wiring a Log implementation for each 
LogFactory.getLog() would be good enough for a proof-of-principle.

> However I'm not sure how this can be done in practice. This means
> ensuring every class that can potentially use logging must be loaded 
> via
> a custom classloader so that the bytecode can be modified as the .class
> file is read from disk, right?

i'd go for static modification: run an enhancer ant task at a 
commons-digester.jar
and create a commons-digester-no-logging.jar with logging turned off. 
custom classloaders seem like a whole lot of no fun...

- robert


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


Re: [logging] bytecode engineering (was: Re: Commons Configuration - Digester Logging turned off)

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On 26 Oct 2004, at 23:58, Michael Schuerig wrote:

> On Wednesday 27 October 2004 00:35, robert burrell donkin wrote:
>> i'd go for static modification: run an enhancer ant task at a
>> commons-digester.jar
>> and create a commons-digester-no-logging.jar with logging turned off.
>
> There already is an ant task that does something pretty similar.
> Just4log surrounds logging calls at bytecode level with something
> equivalent to this
>
> if (logger.isDebugEnabled()) {
>     logger.debug(...);
> }
>
> Just4log uses BCEL and supports Commons Logging, Log4J, JDK 1.4 
> Logging.
>
> See http://just4log.sourceforge.net/

that looks very cool indeed :)

it's similar without being quite the same. the idea would be to replace 
the call to the LogFactory.getLog call with a call returning a direct, 
fast implementation.

i'm interested to see that the project uses BCEL directly rather than 
CGLIB. anyone have any opinions about this?

- robert


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


Re: [logging] bytecode engineering (was: Re: Commons Configuration - Digester Logging turned off)

Posted by Michael Schuerig <mi...@schuerig.de>.
On Wednesday 27 October 2004 00:35, robert burrell donkin wrote:
> i'd go for static modification: run an enhancer ant task at a
> commons-digester.jar
> and create a commons-digester-no-logging.jar with logging turned off.

There already is an ant task that does something pretty similar. 
Just4log surrounds logging calls at bytecode level with something 
equivalent to this

if (logger.isDebugEnabled()) {
    logger.debug(...);
}

Just4log uses BCEL and supports Commons Logging, Log4J, JDK 1.4 Logging.

See http://just4log.sourceforge.net/

Michael

-- 
Michael Schuerig                       Face reality and stare it down
mailto:michael@schuerig.de        --Jethro Tull, Silver River Turning
http://www.schuerig.de/michael/

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