<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
log.trace
log.debug
log.info
log.warn
log.error
log.fatal
public class LogExample { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class); }
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class LogTest {
public static void main(String[] args) {
log.debug("dasdasdasd");
log.trace(null);
log.info(null);
log.warn(null);
log.error(null);
}
}
출력
17:17 INFO step04.log.LogTest - null
17:17 WARN step04.log.LogTest - null
17:17 ERROR step04.log.LogTest - null
INFO, WARN, ERROR만 출력이 되는데 이때 trace까지 출력을 하고 싶거나 debug를 출력하고 싶다면?
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!-- -->
<encoder>
<Pattern>%d{HH:mm} %-5level %logger{36} - %msg%n</Pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>