Programing/Java

SLF4J(Simple Logging Facade for Java)

BUST 2018. 9. 1. 17:38

SLF4J(Simple Logging Facade for Java)

  • 다양한 Logging Framework (java.util.logging, logback, log4j)를 동일한 인터페이스를 통해 Logging을 기능을 제공


Hello World

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

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


아래와 같은 에러메시지가 난다면


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.


Logger가 Bind이 되지 않아 생긴 나온 에러 아래의 Dependency를 추가해야 된다.

slf4j-api-1.8.0-beta2.jar

slf4j-simple-1.8.0-beta2.jar



click to enlarge




click to enlarge


log4j-over-slf4j


'Programing > Java' 카테고리의 다른 글

Guava Cache  (0) 2018.09.12
Singleton Pattern  (0) 2018.09.06
Executor service  (0) 2018.08.31
Java Generic (제너릭)  (0) 2018.08.14
GC overhead limit exceeded  (0) 2018.08.10