#日志相关配置
logging:
config: classpath:logback-test-spring.xml
file:
path: ./pringBootWorkBook/loggggs
level:
#取消CONDITIONS EVALUATION REPORT 信息
org:
springframework:
boot:
autoconfigure: info
io:
swagger:
models:
parameters:
AbstractSerializableParameter: error
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<!-- 属性文件:在properties文件中找到对应的配置项 -->
<springProperty scope="context" name="logging.file.path" source="logging.file.path"/>
<contextName>springBootWorkBook</contextName>
<!--控制台输出-->
<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出(配色):%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 %red([%thread]) %class{36} %magenta(%msg) %yellow(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %cyan(%logger{50}) %magenta(%msg) %n-->
<!--可以打印出来sql-->
<!-- <pattern>%msg%n</pattern>-->
<!-- 这个打印不了sql语句-->
<pattern>%yellow(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %cyan(%logger{50}) %magenta(%msg) %n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--debug-->
<appender name="fileDebugLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{50} - %msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--按时间保存日志 修改格式可以按小时、按天、月来保存-->
<fileNamePattern>${logging.file.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!--保存时长-->
<MaxHistory>90</MaxHistory>
<!--文件大小-->
<totalSizeCap>10MB</totalSizeCap>
</rollingPolicy>
</appender>
<!--info-->
<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{50} - %msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--按时间保存日志 修改格式可以按小时、按天、月来保存-->
<fileNamePattern>${logging.file.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!--保存时长-->
<MaxHistory>90</MaxHistory>
<!--文件大小-->
<totalSizeCap>10MB</totalSizeCap>
</rollingPolicy>
</appender>
<!--warn-->
<appender name="fileWarnLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{50} - %msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--按时间保存日志 修改格式可以按小时、按天、月来保存-->
<fileNamePattern>${logging.file.path}/warn.%d{yyyy-MM-dd}.log</fileNamePattern>
<!--保存时长-->
<MaxHistory>90</MaxHistory>
<!--文件大小-->
<totalSizeCap>10MB</totalSizeCap>
</rollingPolicy>
</appender>
<!--error-->
<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>
%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{50} - %msg%n
</pattern>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${logging.file.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!--保存时长-->
<MaxHistory>90</MaxHistory>
<!--文件大小-->
<totalSizeCap>10MB</totalSizeCap>
</rollingPolicy>
</appender>
<!-- 异步输出,异步的log片段必须在同步段后面,否则不起作用 -->
<appender name="consoleLogAsync" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="consoleLog"/>
</appender>
<appender name="fileDebugLogAsync" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="fileDebugLog"/>
</appender>
<appender name="fileInfoLogAsync" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="fileInfoLog"/>
</appender>
<appender name="fileWarnLogAsync" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="fileWarnLog"/>
</appender>
<appender name="fileErrorLogAsync" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="fileErrorLog"/>
</appender>
<!--level =debug 可以打印sql语句-->
<root level="debug">
<appender-ref ref="consoleLogAsync"/>
<appender-ref ref="fileDebugLogAsync"/>
<appender-ref ref="fileInfoLogAsync"/>
<appender-ref ref="fileWarnLogAsync"/>
<appender-ref ref="fileErrorLogAsync"/>
</root>
</configuration>