无法禁用log4j2中来自第3方jar的日志

时间:2018-08-23 13:50:23

标签: logging configuration apache-kafka log4j2

我正在使用log4j2 kafka附加程序,并从“ org.apache.kafka”获取过多日志记录,例如:

16:30:48.215 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name failed-authentication:
16:30:48.216 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name bytes-sent-received:
16:30:48.216 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name bytes-sent:
16:30:48.217 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name bytes-received:
16:30:48.217 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name select-time:
16:30:48.218 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name io-time:
16:30:48.219 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name batch-size
16:30:48.219 [main] DEBUG o.a.kafka.common.metrics.Metrics - Added sensor with name compression-rate

我仅使用log4j2.xml进行配置,除了用于控制台的输出外,它对我所有其他附加程序都适用。 我尝试使用以下方法关闭此kafka记录器:

<Logger name="org.apache.kafka" level="off" additivity="false"/>

但是没有成功。我什至试图关闭整个输出到控制台,但是此日志一直显示。

有人对此问题提出建议吗?难道我做错了什么? 这是我的整个log4j2.xml配置,仍然显示了kafka日志记录:

<Configuration monitorInterval="30" status="WARN">
<Properties>
    <Property name="baseLogPath">/opt/taptica/trk/logs/</Property>
    <Property name="hitsPath">/etl_files/004/</Property>
    <Property name="conversionsPath">/etl_files_conversions/004/</Property>
    <Property name="postBackPath">/postBack/</Property>
    <Property name="statisticsPath">/opt/taptica/trk/logs/statistics/</Property>
    <!-- <Property name="hostName">${env:HOSTNAME}</Property> -->
    <Property name="kafkaProducers">
        kafka-prod-01.nyj.taptica.info:9092,kafka-prod-02.nyj.taptica.info:9092,kafka-prod-03.nyj.taptica.info:9092
    </Property>
    <Property name="patternTemplae">
        {"timestamp":"%d{dd MMM yyyy HH:mm:ss.SSS}","app":"Tracker","level":"%-5level","thread":"%thread","class":"%logger{1}"%message}%n
    </Property>
</Properties>
<Filters>
    <MarkerFilter marker="SQL" onMatch="NEUTRAL" onMismatch="NEUTRAL"/>
</Filters>
<Appenders>
    <Console name="Console" target="SYSTEM_OUT">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
    </Console>
    <RollingRandomAccessFile name="TrkLog" fileName="${baseLogPath}trk.log" filePattern="{baseLogPath}trk-%d{MM-dd-yyyy@HH:mm}-%i.log.gz">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="500 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="100"/>
    </RollingRandomAccessFile>
    <RollingRandomAccessFile name="NettyLog" fileName="${baseLogPath}netty.log" filePattern="{baseLogPath}netty-%d{MM-dd-yyyy@HH:mm}-%i.log.gz">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="500 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="100"/>
    </RollingRandomAccessFile>
    <RollingRandomAccessFile name="FilterLog" fileName="${baseLogPath}filter.log" filePattern="{baseLogPath}filter-%d{MM-dd-yyyy@HH:mm}-%i.log.gz">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="500 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="100"/>
    </RollingRandomAccessFile>
    <RollingRandomAccessFile name="RequestFile" fileName="${baseLogPath}request.log" filePattern="{baseLogPath}request-%d{MM-dd-yyyy@HH:mm}-%i.log.gz">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="500 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="100"/>
    </RollingRandomAccessFile>
    <RollingRandomAccessFile name="ResponseFile" fileName="${baseLogPath}response.log" filePattern="{baseLogPath}response-%d{MM-dd-yyyy@HH:mm}-%i.log.gz">
        <PatternLayout>
            <Pattern>${patternTemplae}</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="500 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="100"/>
    </RollingRandomAccessFile>
    <!-- Pixel Appender -->
    <RollingRandomAccessFile name="t1PixelFile" fileName="${baseLogPath}t1pixel.log" filePattern="${hitsPath}t1pixel_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="false">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Impression Appender -->
    <RollingRandomAccessFile name="t1ImpressionFile" fileName="${baseLogPath}t1impression.log" filePattern="${hitsPath}t1imp_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="true">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
            <TimeBasedTriggeringPolicy interval="10000" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Click Appender -->
    <RollingRandomAccessFile name="t1ClickFile" fileName="${baseLogPath}t1click.log" filePattern="${hitsPath}t1click_%d{MM-dd-yyyy-HH-mm-ss}%i.gz" immediateFlush="true">
        <Policies>
            <SizeBasedTriggeringPolicy size="10 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Conversion Appender -->
    <RollingRandomAccessFile name="t1ConversionFile" fileName="${baseLogPath}t1conversion.log" filePattern="${conversionsPath}t1conv_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="true">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Goal Appender -->
    <RollingRandomAccessFile name="t1GoalFile" fileName="${baseLogPath}t1goal.log" filePattern="${conversionsPath}t1goal_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="true">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
            <TimeBasedTriggeringPolicy interval="10000" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- RTB Click Appender -->
    <RollingRandomAccessFile name="rtbClickFile" fileName="${baseLogPath}rtbclick.log" filePattern="${hitsPath}rtbclick_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="true">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
            <TimeBasedTriggeringPolicy interval="10000" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- RTB Impression Appender -->
    <RollingRandomAccessFile name="rtbImpressionFile" fileName="${baseLogPath}rtbimpression.log" filePattern="${hitsPath}rtbimp_%d{MM-dd-yyyy-HH-mm-ss-SSS}.gz" immediateFlush="false">
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB"/>
            <TimeBasedTriggeringPolicy interval="10000" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Click Statistics Appender -->
    <RollingRandomAccessFile name="eventStatisticsFile" fileName="${baseLogPath}eventStatistics.log" filePattern="${statisticsPath}event_%d{MM-dd-yyyy-HH-mm}.gz" immediateFlush="false">
        <Policies>
            <TimeBasedTriggeringPolicy interval="5" modulate="true"/>
        </Policies>
        <DefaultRolloverStrategy max="200"/>
    </RollingRandomAccessFile>
    <!-- Budget Appender Kafka -->
    <Kafka name="t1BudgetKafka" topic="budget_main" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Postback Appender -->
    <Kafka name="Kafka" topic="postback" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Filter statistics Appender Kafka -->
    <Kafka name="filterStatisticsAppender" topic="tracker_filter_statistics" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Goal Appender Kafka -->
    <Kafka name="t1GoalKafka" topic="goals_main" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Click Appender Kafka -->
    <Kafka name="t1ClickKafka" topic="clicks_main" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Impression Appender Kafka -->
    <Kafka name="t1ImpressionKafka" topic="impressions_main" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
    <!-- Conversionn Appender Kafka -->
    <Kafka name="t1ConversionKafka" topic="conversions_main" syncSend="true">
        <PatternLayout pattern="%message"/>
        <Property name="bootstrap.servers">${kafkaProducers}</Property>
    </Kafka>
</Appenders>
<Loggers>
    <Logger name="EventStatistics" level="info" additivity="false">
        <AppenderRef ref="eventStatisticsFile"/>
    </Logger>
    <Logger name="T1PixelHits" level="info" additivity="false">
        <AppenderRef ref="t1PixelFile"/>
    </Logger>
    <Logger name="T1ImpressionHits" level="info" additivity="false">
        <AppenderRef ref="t1ImpressionFile"/>
    </Logger>
    <Logger name="T1ImpressionHitsKafka" level="info" additivity="false">
        <AppenderRef ref="t1ImpressionKafka"/>
    </Logger>
    <Logger name="T1ClickHits" level="info" additivity="false">
        <AppenderRef ref="t1ClickFile"/>
    </Logger>
    <Logger name="T1ClickHitsKafka" level="info" additivity="false">
        <AppenderRef ref="t1ClickKafka"/>
    </Logger>
    <Logger name="T1ConversionHitsKafka" level="info" additivity="false">
        <AppenderRef ref="t1ConversionKafka"/>
    </Logger>
    <Logger name="T1ConversionHits" level="info" additivity="false">
        <AppenderRef ref="t1ConversionFile"/>
    </Logger>
    <Logger name="T1GoalHitsKafka" level="info" additivity="false">
        <AppenderRef ref="t1GoalKafka"/>
    </Logger>
    <Logger name="T1GoalHits" level="info" additivity="false">
        <AppenderRef ref="t1GoalFile"/>
    </Logger>
    <Logger name="RtbClickHits" level="info" additivity="false">
        <AppenderRef ref="rtbClickFile"/>
    </Logger>
    <Logger name="RtbImpressionHits" level="info" additivity="false">
        <AppenderRef ref="rtbImpressionFile"/>
    </Logger>
    <Logger name="ResponseLogger" level="info" additivity="false">
        <AppenderRef ref="ResponseFile"/>
    </Logger>
    <Logger name="RequestLogger" level="info" additivity="false">
        <AppenderRef ref="RequestFile"/>
    </Logger>
    <Logger name="filterLogger" level="INFO" additivity="false">
        <AppenderRef ref="FilterLog"/>
    </Logger>
    <Logger name="nettyLogger" level="error" additivity="false">
        <AppenderRef ref="NettyLog"/>
    </Logger>
    <Logger name="T1PostBackLogger" level="INFO" additivity="false">
        <AppenderRef ref="Kafka"/>
    </Logger>
    <Logger name="T1BudgetKafka" level="info" additivity="false">
        <AppenderRef ref="t1BudgetKafka"/>
    </Logger>
    <Logger name="FilterStatisticsKafkaProducer" level="INFO" additivity="false">
        <AppenderRef ref="filterStatisticsAppender"/>
    </Logger>
    <Logger name="org.apache.kafka" level="off" additivity="false"/>
    <Root level="off" additivity="false">
        <AppenderRef ref="Console"/>
        <AppenderRef ref="TrkLog"/>
    </Root>
</Loggers>

0 个答案:

没有答案