一、maven配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
二、slf4j配置
<RollingFile name="RootAppender" fileName="***.log"
filePattern="***.log">
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
</RollingFile>
<Loggers>
<Root level="INFO">
<AppenderRef ref="RootAppender"/>
</Root>
</Loggers>
三、插入日志代码
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("info日志输出信息:");
logger.debug("debug日志输出信息:");
logger.trace("trace日志输出信息:");
logger.error("error日志输出信息:");
logger.warn("warn日志输出信息:");
四、配置日志输出路径
//在项目盘符下创建文件,可以更改绝对路径
logging.file=/springBoot.txt