[slf4j-dev] Repost

Ceki Gulcu listid at qos.ch
Mon Aug 25 15:53:21 CEST 2008


Thank you for posting your message.

For those who missed older messages, Thorbjørn  is adapting his work on adding 
logging statements on classes through byte code generation. This was published 
in an article entitled "Add Logging at Class Load Time with Java 
Instrumentation". The URL is

http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html

More comments inline.

Thorbjørn Ravn Andersen wrote:
[snip]

> I've signed the CLA but not actually mailed it yet, and started looking 
> at doing the necessary changes to make a production strength package 
> (and looking into performance later).  I suggest the using the 
> org.slf4j.instrumentation package for this. 

OK.

> I still keep the "if (log.isDebugEnabled()) log.debug("a=" + a + ", b=" 
> + b))" approach as it avoids having to do the equivalent of autoboxing 
> when creating the objects to pass.  Also it works for me :)

Have you looked at the code in org.slf4j.ext.XLogger? There is some overlap in 
intent or even complementarity. In particular, you could pass on the intercepted 
method parameters to XLogger.enrty(Object... argArray) and the intercepted 
return value to XLogger.exit(Object result).

> Please note that each Java agent must be present in an executable jar, 
> which in turn means that you can maximally have one agent in a given 
> jar.    There is also the issue of the supportive javassist library, so 
> if the license permits I suggest that this agent jar is a single 
> download containing only the agent code with the javassist library 
> enclosed, and that it is kept seperate and named accordingly.

I have not used javassist before. AFAIL, Cglib and ASM are better known. Cglib 
ships with Hibernate, so many application may already have it as a dependency. 
ASM is very well documented and powerful. Was a there a particular reason for 
choosing javassist instead of the more popular cglib? Looking at Hibernate 3.3, 
it seems that both javaassist and cglib have become optional dependencies. Go 
figure.

Are you suggesting that the contents of javassit.jar be merged into 
slf4j-ext.jar (assuming your instrumentation code goes into slf4j-ext.jar)?

> It is not necessary to embed the slf4j API in it as this should be 
> available in the main application at the time when this code runs.

Yes.


> A thing that might be interesting to have on the slf4j web site is a new 
> section to the user guide named "Best practices" or similar.  This might 
> get suitable attention and give some suitable help.  I have dug up the 
> XML-snippet that makes Eclipse insert a logger defintiion when creating 
> a new class. That would be perfect.

We already have an FAQ. Please post a patch with the changes you have in mind.


-- 
Ceki Gülcü




More information about the slf4j-dev mailing list