Java Core
    Java - Overview
    What is new in Java 21
    What is new in Java 17
    What is new in Java 11
    Java - JVM
    Java - Deprecated
    Java - Numbers
    Java - String
    Java - Time
    Java - Collections
    Java - Lambda
    Java - Exceptions
    Java - Switch
    Java - IO
    Java - Jar
    Java - Generics
    Java - Environment
    Java - Concurrency
    Java - Trouble Shooting
    Java - Install
    Java - Misc


Updated: 2021-11-19


In pom, only depend on slf4j-log4j12, it will grab slf4j-api and log4j


In Java

In Java, declare as private static final and use all capital letters LOG to comply with Java coding convention.

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

public class HelloWorld {

    private static final Logger LOG = LoggerFactory.getLogger(HelloWorld.class);

    public static void main(String[] args) {"Hello World");


The code is simple, not depending on classloader, so cannot specify which binding to load.

In exchange for that simplicity, it is the responsibility of person who deploy the package to make sure there is ONE AND ONLY ONE binding jar in CLASSPATH.

"Select logging framework at deployment time", not by configuration but by putting the correct jar in CLASSPATH.



SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.


Jars of slf4j cannot be found in CLASSPATH.


Add the path to CLASSPATH, e.g. in ~/.bashrc