use slf4j logging

Skip to first unread message


Apr 6, 2011, 11:29:32 AM4/6/11
to guava-discuss

I just started using Guava and I noticed that the classes all log to
java.util.logging. I was wondering if there were any plans to switch
to slf4j?

Brent Payne

Apr 6, 2011, 1:53:03 PM4/6/11
to ilinkuo, guava-discuss
For those of us unfamiliar with slf4j, can you express the benefits of
switch to slf4j?

> --
> Project site:
> This group:
> This list is for general discussion.
> To report an issue:
> To get help: (use the tag "guava")

Kevin Bourrillion

Apr 6, 2011, 2:28:03 PM4/6/11
to Brent Payne, ilinkuo, guava-discuss
Guava really doesn't want to start taking on non-JDK dependencies, though.
Kevin Bourrillion @ Google

Chris Tucker

Apr 6, 2011, 2:42:31 PM4/6/11
to Kevin Bourrillion, Brent Payne, ilinkuo, guava-discuss
It's also (relatively) simple to bridge JUL to SLF4J to unify logging however one likes, without Guava having to know anything about SLF4J:


I-Lin Kuo

Apr 6, 2011, 3:45:17 PM4/6/11
to Brent Payne, guava-discuss
slf4j is a logging abstraction framework that abstracts away the actual logging implementation that you are using. It's the same idea as Apache Commons Logging but it's a successful implementation (I regard ACL as a failed attempt).

I like it because I don't want my libraries dictating to me what logging implementation I should use. If Guava uses JUL and another library uses log4j, and a third uses ACL then I'm stuck with two or more log files and two or more log configurations. 

But I see the point of not having non JDK dependencies.

Chris Tucker's suggestion about JUL to SLF4J bridging will probably work for me.

I-Lin Kuo

Nikolas Everett

Apr 6, 2011, 3:48:16 PM4/6/11
to I-Lin Kuo, Brent Payne, guava-discuss
The thing about that bridging is that it really is slow (when not logging) so only use it as a last resort.  The fact that I've never needed Guava's logging really is a testament to it's quality.


Chris Tucker

Apr 6, 2011, 4:27:16 PM4/6/11
to Nikolas Everett, I-Lin Kuo, Brent Payne, guava-discuss
You should be able to avoid the performance issues if you use a recent slf4j using the LevelChangePropagator, documented on the page I linked earlier (caveat: I've not used this myself so I can't say how true the assertion there really is, but I have no reason to be doubt it).


Nikolas Everett

Apr 6, 2011, 4:30:54 PM4/6/11
to, I-Lin Kuo, Brent Payne, guava-discuss
Oh!  Serves me right for not rechecking the page in a while.
Reply all
Reply to author
0 new messages