<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="mainServer_Error"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <file>/opt/fanqizha_tomcat/python/logs/antifraud_Error.log</file> -->
<file>E:/logs/antifraud_Error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>60</maxHistory>
<fileNamePattern>logs/antifraud_Error_%d{yyyy-MM-dd}_%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<immediateFlush>true</immediateFlush>
<pattern>[%level][%d{yyyy-MM-dd}%d{HH:mm:ss:SSS}][%thread][%logger{40}]-
%msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印ERROR日志 -->
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="mainServer"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>E:/logs/antifraud.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>60</maxHistory>
<fileNamePattern>logs/antifraud_%d{yyyy-MM-dd}_%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<immediateFlush>true</immediateFlush>
<pattern>[%level][%d{yyyy-MM-dd}%d{HH:mm:ss:SSS}][%thread][%logger{40}]-
%msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> --><!-- 只打印INFO日志 -->
<level>DEBUG</level>
<!-- <level>INFO</level> -->
<!-- <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> -->
</filter>
</appender>
<appender name="serviceAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>E:/logs/service.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>60</maxHistory>
<fileNamePattern>logs/service_%d{yyyy-MM-dd}_%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<immediateFlush>true</immediateFlush>
<pattern>%msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> --><!-- 只打印INFO日志 -->
<!-- <level>DEBUG</level> -->
<level>DEBUG</level>
<!-- <onMatch>DENY</onMatch> <onMismatch>ACCEPT</onMismatch> -->
<!-- <level>INFO</level> -->
<!-- <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> -->
</filter>
</appender>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%level][%d{yyyy-MM-dd}
%d{HH:mm:ss:SSS}][%thread][%logger{40}]- %msg%n</pattern>
</encoder>
</appender>
<appender name="asyncMain" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="mainServer" />
</appender>
<logger name="com.geo.antifraud.core.mapper" level="DEBUG" />
<logger name="com.geo.antifraud.core.controller.LoggerRecordUtil"
level="DEBUG" additivity="false">
<appender-ref ref="serviceAppender" />
<appender-ref ref="mainServer_Error" />
</logger>
<root level="INFO">
<appender-ref ref="mainServer_Error" />
<!-- <appender-ref ref="mainServer"/> -->
<!-- <appender-ref ref="serviceAppender" /> -->
<appender-ref ref="asyncMain" />
<appender-ref ref="console" />
</root>
</configuration>
logback 根据不同业务打印日志到不同的文件
最新推荐文章于 2023-06-09 17:28:45 发布