xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>myProject</contextName>
<property name="log.path" value="log"/>
<property name="log.maxHistory" value="15"/>
<property name="log.colorPattern"
value="%d{yyyy-MM-dd HH:mm:ss} | %highlight(%-5level) | %boldYellow(%thread) | %boldGreen(%logger) | %msg%n"/>
<property name="log.pattern"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.colorPattern}</pattern>
</encoder>
</appender>
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>${log.maxHistory}</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>NEUTRAL</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<!-- 默认为 ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<!--过滤掉所有日志消息中不包含"IniCronRunner"字符串的日志。-->
<expression>return message.contains(" CONFIG CRON JOB");</expression>
</evaluator>
<!--用于配置符合过滤条件的操作。-->
<OnMatch>DENY</OnMatch>
<!--用于配置不符合过滤条件的操作-->
<OnMismatch>ACCEPT</OnMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="azure_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>
${log.path}/other/azure/azure_log.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<!-- 最多保存30天日志-->
<MaxHistory>30</MaxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!--日志文件最大的大小-->
<maxFileSize>30MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n
</Pattern>
</encoder>
</appender>
<appender name="cron_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>
${log.path}/other/cron/cron_log.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<!-- 最多保存30天日志-->
<MaxHistory>30</MaxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!--日志文件最大的大小-->
<maxFileSize>30MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n
</Pattern>
</encoder>
</appender>
<appender name="api_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>
${log.path}/other/api/api_log.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
<!-- 最多保存30天日志-->
<MaxHistory>30</MaxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!--日志文件最大的大小-->
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n
</Pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="console"/>
</root>
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
<logger name="com.test.system.service.trigger.AzureTrigger" level="info" additivity="true">
<appender-ref ref="azure_log"/>
</logger>
<logger name="com.test.system.schedule">
<appender-ref ref="cron_log"/>
</logger>
<logger name="com.test.system.api">
<appender-ref ref="api_log"/>
</logger>
</configuration>