<?xml version="1.0" encoding="UTF-8"?> <configuration> <substitutionProperty name="log.base" value="d:\\test\\status" /> <!--appender 输出目的地 console 控制台 --> <appender name="console" class="ch.qos.logback.core.ConsoleAppender" target="System.out"> <encoder charset="UTF-8"> <pattern>%date{yyyy-MM-dd HH:mm:ss} [%logger{5}]-[%le] - %m%n</pattern> </encoder> <target>System.out</target> </appender> <!--appender 输出目的地 file 文件 --> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.base}/status.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.base}/status-%d{yyyy-MM-dd-HH}.log</fileNamePattern> </rollingPolicy> <!-- 编码格式解析器 --> <encoder> <pattern>%date{yyyy-MM-dd HH:mm:ss} [%logger]-[%le] - %m%n</pattern> </encoder> </appender> <!-- 数据处理量记录写入目的地 --> <appender name="COUNTER_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.base}/status.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.base}/status-%d{yyyy-MM-dd-HH}.log</fileNamePattern> </rollingPolicy> <!-- 编码格式解析器 --> <encoder> <pattern>%date{yyyy-MM-dd HH:mm},%m%n</pattern> </encoder> </appender> <!-- 数据处理量日志 --> <logger name="counter" level="INFO" additivity="false"> <appender-ref ref="COUNTER_FILE" /> </logger> <!-- 数据处理量记录写入目的地 --> <appender name="queue" class="ch.qos.logback.classic.AsyncAppender"> <discardingThreshold>0</discardingThreshold> <queueSize>10000</queueSize> <appender-ref ref="console" /> </appender> <root level="INFO"> <!-- <appender-ref ref="file" /> --> <appender-ref ref="queue" /> </root> </configuration>
?
?
<?xml version="1.0" encoding="UTF-8"?> <configuration> <!-- 日志存储路径 --> <substitutionProperty name="log.base" value="/logs/status" /> <!--appender 输出目的地 file 文件 --> <appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.base}/status.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.base}/status-%d{yyyy-MM-dd-HH}.log</fileNamePattern> <maxHistory>12</maxHistory> </rollingPolicy> <!-- 编码格式解析器 --> <encoder> <pattern>%date{yyyy-MM-dd HH:mm:ss} [%logger{5}]-[%le] - %m%n</pattern> </encoder> </appender> <!-- 数据处理量记录写入目的地 --> <appender name="COUNTER_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${log.base}/status-l.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.base}/status-l-%d{yyyy-MM-dd}.log</fileNamePattern> </rollingPolicy> <!-- 编码格式解析器 --> <encoder> <pattern>%date{yyyy-MM-dd-HH},%m%n</pattern> </encoder> </appender> <!-- 数据处理量日志 --> <logger name="counter" level="INFO" additivity="false"> <appender-ref ref="COUNTER_FILE" /> </logger> <!-- 日志级别 --> <root level="INFO"> <appender-ref ref="ROLLING_FILE" /> </root> </configuration>
?