<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<springProfile name="dev">
<pattern>%d{yyyy-MM-dd-HH:mm:ss E} %level [%thread]-%class[%line]: %msg%n</pattern>
</springProfile>
<springProfile name="!dev">
<pattern>%d{yyyy-MM-dd-HH:mm:ss E} %level [%thread]-%class[%line]: %msg%n</pattern>
</springProfile>
<!--⽇志的编码格式-->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--这个就表示的是要把 ⽇志输出到⽂件(FileAppender)-->
<appender name="file" class="ch.qos.logback.core.FileAppender">
<file>log/output.log</file>
<!--设置⽇志是否追加-->
<append>true</append>
<encoder>
<pattern>%d{yyyy-MM-dd-HH:mm:ss.SSS} %level [%thread]-
%class:%line>>%msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!--设置⽇志写⼊是否线程安全-->
<prudent>false</prudent>
</appender>
<appender name="timeFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--TimeBasedRollingPolicy 基于时间的滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--每小时生产一个日志文件-->
<fileNamePattern>log/log-%d{yyyy-MM-dd-HH}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd-HH:mm:ss.SSS} %level [%thread]-%class:%line>>%msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="fixedFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>d:/log/fixedFile.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>log/fixedFile%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>10</maxIndex>
</rollingPolicy>
<!--SizeBasedTriggeringPolicy-->
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd-HH:mm:ss.SSS} %level [%thread]-
%class:%line>>%msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="info">
<appender-ref ref="stdout" />
<appender-ref ref="timeFile"/>
</root>
</configuration>