I already talked about Log4J, but not about SLF4J. The Simple Logging Facade for Java is another way



Using SLF4J for the first time:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloWorld {
  public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger(HelloWorld.class);"Hello World");


To migrate to SLF4J from log4J is quick simple since they have a migration tool, with some limitations though.


There are several tutorials on this matter.



Dependencies and underline logger framework

As the tutorial explains, if you use <sl4j-nop:175> you will basically only compile the project ~ getting rid of the sl4j issues.

But to actually use it, you must use logback-classic.jar and logback-core.jar, dependencies.

And in fact, you can stack sl4j above log4j, keeping the logger messages from both.


~ inline

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s