use slf4j logging

455 views
Skip to first unread message

ilinkuo

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

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

unread,
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?

> --
> guava-...@googlegroups.com
> Project site: http://guava-libraries.googlecode.com
> This group: http://groups.google.com/group/guava-discuss
>
> This list is for general discussion.
> To report an issue: http://code.google.com/p/guava-libraries/issues/entry
> To get help: http://stackoverflow.com/questions/ask (use the tag "guava")
>

Kevin Bourrillion

unread,
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
http://guava-libraries.googlecode.com

Chris Tucker

unread,
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: http://www.slf4j.org/legacy.html#jul-to-slf4j

Chris

I-Lin Kuo

unread,
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.

Thanks.
--
I-Lin Kuo

Nikolas Everett

unread,
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.

Nik

Chris Tucker

unread,
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).

Chris

Nikolas Everett

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