« Subversion: Upgrade to 1.6 using 'svnsync', and move projects using 'svnadmin dump' | Main | Geek Tip of the Day »

April 24, 2011

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a0120a5fc12e0970c01538e19bdd6970b

Listed below are links to weblogs that reference Java Logging Reconsidered:

Comments

Dossy

Parameterized logging makes for "cleaner" code visually, but you still pay the price of potentially expensive object serialization. While the conditional wrapper does incur the cost of checking for debug logging twice, that boolean test is likely a LOT cheaper than performing the more expensive object serialization which just gets thrown away inside the method call.

If only Java had nicer closure syntax (i.e., not this anonymous inner class crap) and/or lazy binding and deferred evaluation ...

Michael Andrews

Absolutely. Checking a boolean twice is not very expensive overall. If you are passing a parameter that is expensive to evaluate (like object serialization) - then you still need to do the wrap. Thanks for pointing that out! :)

Javin @ garbage collection in Java

Excellent article , you have indeed covered topic in details with code examples and explanation. I have also blogged some of my logging experience as 10 tips on logging in Java

Thanks
Javin

Simon

A few comments regarding your conclusions on Log4J:

1. Log4J ships with the AsyncAppender in-the-box. That more-or-less takes care of asynchronous logging.

2. Log4J is still being maintained, the most recent release (at the time of writing, May 2011) being 1.2.16, released in April 2010. However, the Log4J 2.0 project does seem to be moribund.

3. Extending Log4J is a piece of cake, e.g. you can provide your own Appender by simply subclassing the abstract AppenderSkeleton class. It's probably equally as easy as java.util.logging.

I'd be very interested to learn how you arrived at the conclusion that LogBack is ten times faster than Log4J? Is that only via the SL4J API? Presumably the difference is considerably smaller (i.e. less than an order of magnitude) when you use the native Log4J API?

Xoán

Thank you, I like this post a lot.

Timberland For Women

Liked you on Facebook, too. =)

ibaca

What happens with the tomcat webapp tips? ;)

SGB

Hi,
Very nice article.
I was trying to understand the nitty gritty of the logging in java too. That said, I am having difficulty making SLF4j and logback work in JBOSS AS 7.1.2. ... as some of my dependencies are including other logging implementations.
I cannot seem to figure out how to exclude them.
If time permits, could you please give a tutorial on how to use it.

-SGB

Michael Andrews

SGB - You'll need to bridge those other logging implementations to SLF4J. You'll then be able to pick the runtime implementation for your app. I use Logback at runtime. Here are my maven dependencies when I'm depending on JARs that use JUL, Commons, and Log4J. Hope this helps.

            
            
                org.slf4j
                slf4j-api
                ${slf4j.version}
            
            
                org.slf4j
                jcl-over-slf4j
                ${slf4j.version}
                runtime
             
            
                org.slf4j
                log4j-over-slf4j
                ${slf4j.version}
                runtime
             
            
                org.slf4j
                jul-to-slf4j
                ${slf4j.version}
                runtime
            
            
                ch.qos.logback
                logback-classic
                1.0.7
                runtime
            
Michael Andrews

the system removed the POM tags - but you get the idea. Here is a link to the docs on this.

http://www.slf4j.org/legacy.html

M

The comments to this entry are closed.