[jboss-dev] Something of interest to anyone who has to deal with java.util.logging vs. log4j vs. commons-logging vs. ....

David M. Lloyd david.lloyd at jboss.com
Tue Nov 7 21:09:32 EST 2006


In the course of developing and debugging the jBPM web app (which uses a
number of Sun libraries), I dusted off and finished an old thing I had
started a while ago which basically adapts java.util.logging into log4j.
I was telling Jason Greene about it and he suggested I forward it on to
you to see what you think of it.

I put the source into my personal repository at
http://svn.flurg.com/java/logbridge ... also I've created a release of
the current stable version which can be gotten directly from
http://java.flurg.com/downloads/logbridge-1.0.0.jar .

Basically you use it by passing
"-Djava.util.logging.manager=logbridge.SourceLogManager" to the JVM at
startup.  You also have to have log4j in your initial classpath (this
kinda sucks but I can't think of another way around it).

It works by creating a custom LogManager that replaces the standard
Logger with one that wraps an equivalent log4j Logger.  Also it maps log
levels in a fairly intuitive way (at least, in my opinion).  There's
some weak reference stuff in there to make sure that it doesn't hold on
to other people's classloaders.

Anyway, have a look if you want.  I didn't spend too much time on it,
because I'm sure if I did, Tom would give me a hard time about it. :-)

But I admit that I envision this kind of thing as a replacement for
commons logging.  People can just use the logging API built in to their
JVM, and we catch it and make it look nice in our log file by using the
log4j appenders instead.

- DML




More information about the jboss-development mailing list