我是靠谱客的博主 粗心大雁,最近开发中收集的这篇文章主要介绍标准logback.xml日志模版,拿去就用,别整那些花里胡哨的,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true">
<property name="baseDir" value="logs"/>
<property name="maxHistory" value="30"/>
<property name="maxFileSize" value="100MB"/>
<property name="logPatten" value="%date{yyyy-MM-dd HH:mm:ss}|%-5level|%thread|%file:%line|%logger|%msg%n"/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%yellow(%date{yyyy-MM-dd HH:mm:ss})|%highlight(%-5level)|%blue(%thread)|%blue(%file:%line)|%green(%logger)|%cyan(%msg%n)</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>trance</level>
</filter>
</appender>
<appender name="trace" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${baseDir}/trace/%d{yyyy-MM-dd}/%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
<MaxHistory>${maxHistory}</MaxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${logPatten}</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>trace</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${baseDir}/debug/%d{yyyy-MM-dd}/%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
<MaxHistory>${maxHistory}</MaxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${logPatten}</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${baseDir}/info/%d{yyyy-MM-dd}/%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
<MaxHistory>${maxHistory}</MaxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${logPatten}</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${baseDir}/warn/%d{yyyy-MM-dd}/%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
<MaxHistory>${maxHistory}</MaxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${logPatten}</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${baseDir}/error/%d{yyyy-MM-dd}/%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
<MaxHistory>${maxHistory}</MaxHistory>
<maxFileSize>${maxFileSize}</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${logPatten}</pattern>
<charset>utf-8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>error</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="error">
<appender-ref ref="stdout"/>
<appender-ref ref="trace"/>
<appender-ref ref="debug"/>
<appender-ref ref="info"/>
<appender-ref ref="warn"/>
<appender-ref ref="error"/>
</root>
<logger name="com.wxy" level="debug"/>
</configuration>

最后

以上就是粗心大雁为你收集整理的标准logback.xml日志模版,拿去就用,别整那些花里胡哨的的全部内容,希望文章能够帮你解决标准logback.xml日志模版,拿去就用,别整那些花里胡哨的所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部