log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="info">
<appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %t %-5level %logger{30}.%method - %msg%n"/>
</Console> <!--默认按天&按512M文件大小切分日志,默认最多保留30个日志文件,非阻塞模式-->
<XMDFile name="infoAppender" fileName="info.log" sizeBasedTriggeringSize="512M"
rolloverMax="">
<Filters>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</XMDFile> <XMDFile name="warnAppender" fileName="warn.log" sizeBasedTriggeringSize="512M"
rolloverMax="">
<Filters>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</XMDFile> <XMDFile name="errorAppender" fileName="error.log" sizeBasedTriggeringSize="512M"
rolloverMax="">
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
</XMDFile> <!--日志远程上报-->
<Scribe name="ScribeAppender">
<!--远程日志默认使用appkey作为日志名(app.properties文件中的app.name字段),也可自定义scribeCategory属性,scribeCategory优先级高于appkey-->
<LcLayout/>
</Scribe>
<Async name="ScribeAsyncAppender" blocking="false">
<AppenderRef ref="ScribeAppender"/>
</Async> <!--hive日志远程上报-->
<Scribe name="ScribeHiveAppender">
<!--远程日志默认使用appkey作为日志名(app.properties文件中的app.name字段),也可自定义scribeCategory属性,scribeCategory优先级高于appkey-->
<Property name="scribeCategory">qcs.regulation.jiaotongbu</Property>
<LcLayout/>
</Scribe>
<Async name="XMDFileAppender" blocking="false">
<AppenderRef ref="ScribeHiveAppender"/>
</Async> <CatAppender name="catAppender"/> </appenders> <loggers>
<logger name="hive-logger" additivity="false">
<AppenderRef ref="XMDFileAppender"/>
<appender-ref ref="ScribeAsyncAppender"/>
</logger> <logger name="com.sankuai.qcs.regulation" additivity="false">
<appender-ref ref="ScribeAsyncAppender"/>
<appender-ref ref="infoAppender"/>
<appender-ref ref="warnAppender"/>
<appender-ref ref="errorAppender"/>
<appender-ref ref="catAppender"/>
</logger> <!--其他日志-->
<root level="info">
<appender-ref ref="warnAppender"/>
<appender-ref ref="errorAppender"/>
<appender-ref ref="Console"/>
<appender-ref ref="catAppender"/>
</root>
</loggers>
</configuration>

其中 最后的:

<root level="info">
<appender-ref ref="warnAppender"/>
<appender-ref ref="errorAppender"/>
<appender-ref ref="Console"/>
<appender-ref ref="catAppender"/>
</root>
指的是<!-- 设置根日志级别,指定路径中的日志优先级大于根日志优先级
如果设置了level=info 就是说 根目录会打印info以上的信息;
参考:Log4J日志信息配置文件详解
上一篇:Python学习笔记整理总结【web基础】【web/HTML/CSS/JavaScript/DOM/jQuery】


下一篇:xamarin.android 给View控件 添加数字提醒效果-BadgeView