Maven依赖
org.springframework.boot spring-boot-starter-log4j2 org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-logging org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-logging
如果其它依赖有log日志冲突,可以加入下面配置:
log4j * org.slf4j * org.apache.logging.log4j *
log4j2.xml
放在resources目录下
LogTest.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LogTest {
public final Logger logger=LoggerFactory.getLogger(getClass());
public static void main(String[] args) {
log.trace("trace");
log.debug("debug");
log.warn("warn");
log.info("info");
log.error("error");
}
}










