Spring Boot 2.3.0刚刚发布,在正在开发中的项目中使用了一下,发原有的日志无法正常数据,看了一下官方文档,做了一下改动:
bootstrap.yml中的日志配置
logging:
level:
root: INFO
file:
name: logs/${spring.application.name}.log
bootstrap.yml中原有配置是这样的:
logging:
level:
root: INFO
file: logs/${spring.application.name}.log
附上logback-spring.xml文件的配置,这个是不需要改动的
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include
resource="org/springframework/boot/logging/logback/console-appender.xml" />
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
</encoder>
<file>${LOG_PATH:-.}/${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i</fileNamePattern>
<maxHistory>7</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>5MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
网友评论