In the past developers have used log4j, and Java’s built in logging framework api. Commons logging (JCL) has also been used as a facade to allow easy implementation switching.
Now we also have logback, and the slf4j facade.
So the question is what should we be using to implement logging in our Java application?
Firstly using a facade is recommended. It allows you to far more easily switch the underlying logging implementation without affecting your application code. JCL suffered from a variety of classloader issues that made it troublesome to use. SLF4J has none of these issues and works well as a logging facade and is currently our facade of choice.
For the logging implementation we have long used log4j and it does a good job of providing simple logging capabilities. Our preferred logging framework for new projects however is logback. It includes many improvements over log4j such as:
- more flexible configurations
- implements SLF4J natively