pom.xml加入
ch.qos.logback logback-classic 1.1.7 org.slf4j slf4j-api 1.7.21
classpath下新增logback.xml
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n /opt/logs/xxx.log %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n /opt/logs/xxx.log.%d{yyyyMMddHH}
代码中使用:
import org.slf4j.Logger;import org.slf4j.LoggerFactory;private static Logger logger = LoggerFactory.getLogger(MainBoot.class);