How to use slf4j
Java의 주요 Logging Framework
- java.util.logging : Not used recently
- Log4J : Generally used
- Logback : Similar to Log4J (same developer)
- SLF4J : facade pattern
- tinylog : 75KB Jar framework
Apache logging service
SLF4J(Simple Logging Facade for Java) org.slf4j.LoggerFactory
Add jar files
- log4j-1.2.17.jar
- slf4j-api-1.8.28.jar
- slf4j-log4j12-1.7.28.jar
#pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Sample {
final Logger logger = LoggerFactory.getLogger(Sample.class);
public void run() {
logger.debug("debug");
logger.info("info");
}
}
Leave a comment