Tuesday, November 6, 2012

Logback a successor to log4j

There are different logging frameworks we use for eg log4j, Apache logger, tinilog, slf4j , java.util.logging (JUL).


In this blog we are going to talk on  Logback  which is an implementation of Slf4j API and provides various new features log4j currently does not provide.

There are number of reasons we should prefer to use logback over traditinal log4j.

  • Faster implementation
  • Extensive battery of tests: logging framework to be rock solid and dependable even under adverse conditions.
  • logback-classic speaks SLF4J natively
  • Extensive documentation
  • Automatic reloading of configuration files
  • Graceful recovery from I/O failures
  • Automatic removal of old log archives
  • Automatic compression of archived log files
  • Prudent mode on multiple JVM's
  • Conditional processing of configuration files
  • Filters   
  • SiftingAppender
  • Stack traces with packaging data
  • Logback-access: the logback-access module integrates with Servlet containers, such as Tomcat and Jetty, to provide HTTP-access log functionality. Note that you could easily build your own module on top of logback-core. 
  •  We can change the different logging level programatically
  • Switching back to slf4j with least changes
  The above reasons are enough to motivate us in using this logback framework.

Structure:
logback is divided into three modules, logback-core, logback-classic and logback-access.
 

Lisencing:
Please note that log4j is lisenced under Apache lisencing where as logback is under

EPL v1.0 and the LGPL 2.1.

How to use:
Use the slf4j logger classes in your code and the add logback.jar and logback.xml to the  classpath.


For more refer to the project site :http://logback.qos.ch/

No comments:

Post a Comment