42 lines
1.9 KiB
XML
42 lines
1.9 KiB
XML
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|||
|
<configuration>
|
|||
|
<!--包含Spring boot对logback日志的默认配置-->
|
|||
|
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
|||
|
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
|
|||
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
|
|||
|
|
|||
|
<!--重写了Spring Boot框架 org/springframework/boot/logging/logback/file-appender.xml 配置-->
|
|||
|
<appender name="TIME_FILE"
|
|||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|||
|
<encoder>
|
|||
|
<pattern>${FILE_LOG_PATTERN}</pattern>
|
|||
|
</encoder>
|
|||
|
<file>${LOG_FILE}</file>
|
|||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|||
|
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i</fileNamePattern>
|
|||
|
<!--
|
|||
|
Spring Boot默认情况下,日志文件10M时,会切分日志文件,这样设置日志文件会在100M时切分日志
|
|||
|
-->
|
|||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|||
|
<maxFileSize>10MB</maxFileSize>
|
|||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
|||
|
|
|||
|
</rollingPolicy>
|
|||
|
</appender>
|
|||
|
|
|||
|
<root level="INFO">
|
|||
|
<appender-ref ref="CONSOLE" />
|
|||
|
<appender-ref ref="TIME_FILE" />
|
|||
|
</root>
|
|||
|
|
|||
|
</configuration>
|
|||
|
<!--
|
|||
|
1、继承Spring boot logback设置(可以在appliaction.yml或者application.properties设置logging.*属性)
|
|||
|
2、重写了默认配置,设置日志文件大小在100MB时,按日期切分日志,切分后目录:
|
|||
|
|
|||
|
blog.2017-08-01.0 80MB
|
|||
|
blog.2017-08-01.1 10MB
|
|||
|
blog.2017-08-02.0 56MB
|
|||
|
blog.2017-08-03.0 53MB
|
|||
|
......
|
|||
|
-->
|