概述
logback官方文档地址
http://logback.qos.ch/manual/layouts.html
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.padual.com/java/logback.xsd"
debug="false" scan="true" scanPeriod="30 second">
<property name="FILESIZE" value="50MB" />
<property name="MAXHISTORY" value="100" />
<timestamp key="DATETIME" datePattern="yyyy-MM-dd HH:mm:ss" />
<!-- 控制台打印 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="utf-8">
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p [%X{traceId}/%c{1}] - %m%n
</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<conversionRule conversionWord="host" converterClass="com.XXXX.finance.gateway.core.log.LogHostConfig" />
<conversionRule conversionWord="env" converterClass="com.XXXX.finance.gateway.core.log.LogEnvConfig" />
<conversionRule conversionWord="traceId" converterClass="com.XXXX.finance.gateway.core.log.LogTraceIdConfig" />
<appender name="DEFAULT-APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- All Log Info --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">--> <fileNamePattern>/data/tomcat/logs/biz/biz_gateway-zuul.log.%d{yyyyMMddHH}</fileNamePattern> </rollingPolicy> <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"> <providers> <mdc/> <pattern> <pattern> {"@timestamp": "%date{yyyy-MM-dd HH:mm:ss}","source_host": "${HOSTNAME}","file": "%F","method":"%M","level":"%p","line_number":"%L","thread_name":"%t","@version":1,"logger_name":"%logger","message":"%m","class":"%C","mdc":"%X"} </pattern> </pattern> <stackTrace> <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter"> <maxDepthPerThrowable>100</maxDepthPerThrowable> <maxLength>20480</maxLength> <rootCauseFirst>true</rootCauseFirst> </throwableConverter> </stackTrace> </providers> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>INFO</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender>
<!-- SQL相关日志输出-->
<logger name="org.apache.ibatis" level="INFO" additivity="false" />
<logger name="org.mybatis.spring" level="INFO" additivity="false" />
<!-- Logger 根目录 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="INFO" />
</root>
</configuration>
最后
以上就是结实大米为你收集整理的logback的layout以及encode相关配置的全部内容,希望文章能够帮你解决logback的layout以及encode相关配置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复