zoukankan      html  css  js  c++  java
  • 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="30">
                <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="30">
                <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="30">
                <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日志信息配置文件详解
  • 相关阅读:
    HUST 1372 marshmallow
    HUST 1371 Emergency relief
    CodeForces 629D Babaei and Birthday Cake
    CodeForces 629C Famil Door and Brackets
    ZOJ 3872 Beauty of Array
    ZOJ 3870 Team Formation
    HDU 5631 Rikka with Graph
    HDU 5630 Rikka with Chess
    CodeForces 626D Jerry's Protest
    【POJ 1964】 City Game
  • 原文地址:https://www.cnblogs.com/aspirant/p/10635550.html
Copyright © 2011-2022 走看看