logback配置

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<!-- 应用名称 -->
<property name="APP_NAME" value="lfex_eoa" />
<property name="LOG_HOME" value="/wls/wls81/lfex_eoa_seal/logs/application/eoa" />
<property name="CHARSET" value="UTF-8" />
<!--格式化输出:%d表示日期,%-5level:级别从左显示5个字符宽度,%logger日志类,%L行号,%msg:日志消息,%n是换行符 -->
<property name="LAYOUT_PATTERN" value="[%-5level][%d][%logger{80}|%L] %msg%n" />

<property name="INFO_FILE_NAME" value="eoa_info" />
<property name="ERROR_FILE_NAME" value="eoa_error" />

<contextName>${APP_NAME}</contextName>

<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<chaset>${CHARSET}</chaset>
<pattern class="ch.qos.logback.classic.PatternLayout">${LAYOUT_PATTERN}</pattern>
</encoder>

<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 
<level>INFO</level> 
</filter>
</appender>


<!-- 滚动日志文件 -->
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 日志文件名 -->
<file>${LOG_HOME}/${INFO_FILE_NAME}.log</file>

<!-- 字符集和输出格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<chaset>${CHARSET}</chaset>
<pattern class="ch.qos.logback.classic.PatternLayout">${LAYOUT_PATTERN}</pattern>
</encoder>

<!-- 时间为基础的滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--历史日志文件 -->
<FileNamePattern>${LOG_HOME}/${INFO_FILE_NAME}.%d{yyyyMMdd}.log.gz</FileNamePattern>
<!-- 最多保留30个 -->
<MaxHistory>30</MaxHistory>
</rollingPolicy>

<!-- 日志level -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 
<level>INFO</level>
</filter>
</appender>


<!-- 滚动错误日志文件 -->
<appender name="ERROR_FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 日志文件名 -->
<file>${LOG_HOME}/${ERROR_FILE_NAME}.log</file>

<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<chaset>${CHARSET}</chaset>
<pattern>${LAYOUT_PATTERN}</pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/${ERROR_FILE_NAME}.%d{yyyyMMdd}.log.gz</FileNamePattern>
<!-- 最多保留30个 -->
<MaxHistory>30</MaxHistory>
</rollingPolicy>

<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> 
<level>ERROR</level> 
</filter>
</appender>


<!-- 下面配置一些第三方包的日志过滤级别,用于避免刷屏 -->
<logger name="org.springframework" level="INFO" />
<logger name="org.apache" level="INFO" />
<logger name="org.mybatis" level="INFO" />
<logger name="org.apache.zookeeper" level="INFO" />
<logger name="com.alibaba.dubbo.monitor" level="WARN" />

<!-- 应用日志 -->
<logger name="com.lfex" level="INFO" />

<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
</configuration>


你可能感兴趣的:(logback配置)