[slf4j-user] JUL logs still going to the console

Jeffrey Sinclair jeff at cooljeff.co.uk
Wed May 5 08:47:52 CEST 2010


Hi Phil,

I believe there are two steps to getting the JUL bridge to work:

1. You need to add the jul-slf4j-xxx.jar to your classpath.
2. You need to install the SLF4JBridgeHandler.

For (2) there are two ways to register the SLF4J bridge with JUL. You
can do so programmatically through an API on the SLF4JBridgeHandler
itself [1]. Alternatively the JUL framework takes a system property to
configure the LogManager [2] (-Djava.util.logging.config.class). When
using the system property I think you need to write your own wrapper
class that then installs the SLF4JBridgeHandler, I don't think this
wrapper class is available with SLF4J (someone else can confirm).

I've always used the system property because I cannot be sure that no
JUL calls are made before I get to code I control and hence don't want
to miss any log statements before getting the chance to setup the
bridge.

[1] http://www.slf4j.org/api/org/slf4j/bridge/SLF4JBridgeHandler.html
[2]
http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/LogManager.html

Jeff

On Tue, 2010-05-04 at 12:21 +0200, Philippe Frangioni wrote:
> Hi all,
> I'm working on a Java Application (not a web application) which uses
> log4j.
> But there is a dependency on org.jdesktop package, and this package
> uses java.util.logging.
> As we want all our logging to go to files and to follow the log4j
> configuration, we decided to use the jul-to-slf4j bridge and the log4j
> implementation of slf4j.
> This way, the logs from our code is still "simply" logged with log4j
> and the logs from the org.jdesktop package are routed to slf4j, which
> actually "send" them to log4j as well.
> This is working fine, all the logs are making it to the log files. The
> only problem is that the JUL logs are still going to the console (so
> they go to both the console and the log files), and we would like to
> avoid it.
> 
> Any idea on how to do that?
> Thanks,
> Phil
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://qos.ch/mailman/listinfo/slf4j-user




More information about the slf4j-user mailing list