My favorites | Sign in
Project Logo
                
Code license: Apache License 2.0
Labels: java, log4j, facade
Show all Featured downloads:
log5j-1.2.tar.gz
People details
Project owners:
  burtonator

Logger facade that supports printf style message format for both performance and ease of use.

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

The log5j package supports a 'modernized' interface on top of the class Log4j API usage.

It provides a few syntactic extensions thanks to JDK 1.5 (hence the name log5j).

Usage

First. It is no long required to give log4j the category when creating a new class level logger. Log5j just figures it out from the call stack.

For example old usage for log4j was:

private static final Logger log = Logger.getLogger( FeedTask.class );

and the new syntax with Log5j:

private static final Logger log = Logger.getLogger();

Much better and fixes a lot of copy/paste errors.

Second. It provides sprintf support for logging messages

Before:

log.debug( "This thing broke: " + foo + " due to bar: " + bar + " on this thing: " + car );

After:

log.debug( "This thing broke: %s due to bar: %s on this thing: %s", foo, bar, car );

That is SOOOOOO much better. Good god!

Performance

There's also a performance advantage here.

If you were using log.debug() calls with string concat the strings are CONSTANTLY generated even if the debug level is disabled. This burns CPU and pollutes your heap leading to addition garbage collection.

Now internally the log.debug message isn't even called and the string is never expanded/formatted unless the debug level is enabled.









Hosted by Google Code