<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug" >
<Properties>
<Property name="log_pattern">[vip]%d %-5p [%t] %C{2} (%F:%L) - %m%n</Property>
<property name="file_name">F:/log/vip_error.log</property> <!-- 文件名 -->
<property name="file_name2">F:/log/vip_debug.log</property> <!-- 文件名 -->
<property name="rolling_file_name">F:/log/vip_error_%d{yyyy-MM-dd}-%i.log.gz</property> <!-- 超出4M后生成的文件名 -->
<property name="rolling_file_name2">F:/log/vip_debug_%d{yyyy-MM-dd}-%i.log.gz</property> <!-- 超出4M后生成的文件名 -->
<property name="every_file_size">4KB</property><!-- 日志切割的最小单位 -->
<property name="output_log_level">debug</property><!-- 日志输出级别 -->
<property name="isAppend">true</property><!-- 是否追加日志输出 -->
<property name="maxFile">30</property><!-- 默认日志文件最大数量为:30 -->
</Properties>
<Appenders>
<!-- 输出到控制台的配置 -->
<Console name="STDOUT" target="SYSTEM_OUT">
<!-- 输出格式 -->
<PatternLayout pattern="${log_pattern}" />
</Console>
<!-- 显示error和fatal级别之外的信息 -->
<RollingFile name="RollingFile" fileName="${file_name}"
filePattern="${rolling_file_name}" append="${isAppend}">
<PatternLayout pattern="${log_pattern}" />
<Filters>
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
<ThresholdFilter level="fatal" onMatch="ACCEPT" onMismatch="DENY" />
</Filters>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="${every_file_size}" />
</Policies>
<DefaultRolloverStrategy max="${maxFile}" />
</RollingFile>
<!-- 只保存error和fatal 级别之外的信息 -->
<RollingFile name="RollingFile1" fileName="${file_name2}"
filePattern="${rolling_file_name2}" append="${isAppend}">
<PatternLayout pattern="${log_pattern}" />
<Filters>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL" />
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL" />
<ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY" />
</Filters>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="${every_file_size}" />
</Policies>
<DefaultRolloverStrategy max="${maxFile}" />
</RollingFile>
</Appenders>
<Loggers>
<Root level="${output_log_level}">
<AppenderRef ref="RollingFile" />
<AppenderRef ref="RollingFile1" />
</Root>
</Loggers>
</Configuration>
需要其他的配置的话,就请看下官网上的说明吧:http://logging.apache.org/log4j/2.x/