2015-06-23 85 views
0

我正在使用log4j2以下配置。記錄器「org.apache.solr」使用level =「info」定義,但是我也可以在日誌文件中看到錯誤消息。我試圖確保的是,只有包「org.apache.solr。*」的信息級別日誌纔會發送到flume,其餘部分將記錄到tomcat.log中。log4j2記錄器級別不起作用

<?xml version="1.0" encoding="UTF-8" ?> 
<Configuration status="INFO"> 
<Appenders> 
<RollingRandomAccessFile name="tomcatLog" fileName="/home/jim/logs/tomcat.log" filePattern="/home/jim/logs/$${date:yyyy-MM}/tomcat-%d{yyyy-MM-dd-HH}-%i.log.gz"> 
    <PatternLayout> 
     <Pattern>%d{dd MMM yyyy HH:mm:ss,SSS} %t %p %c{1.} [%F - %L] %m%n</Pattern> 
    </PatternLayout> 

    <Policies> 
     <TimeBasedTriggeringPolicy interval="6" modulate="true"/> 
     <SizeBasedTriggeringPolicy size="250 MB"/> 
    </Policies> 
</RollingRandomAccessFile> 

<Flume name="solrEventLogger" compress="false"> 
    <Property name="channel.type">file</Property> 
    <Property name="channel.checkpointDir">/home/jim/logs/solr/checkpoint</Property> 
    <Property name="channel.dataDirs">/home/jim/logs/solr/data</Property> 

    <Property name="sinks">agent1</Property> 
    <Property name="agent1.channel">file</Property> 
    <Property name="agent1.type">avro</Property> 
    <Property name="agent1.hostname">127.0.0.1</Property> 
    <Property name="agent1.port">61237</Property> 
    <Property name="agent1.batch-size">1</Property> 
      <PatternLayout> 
        <Pattern>%d{dd MMM yyyy HH:mm:ss,SSS} %t %p %c{1.} [%F - %L] %m%n</Pattern> 
      </PatternLayout> 

    <Property name="processor.type">failover</Property> 
</Flume> 
</Appenders> 
<Loggers> 
    <Logger name="org.apache.solr" additivity="true" level="info"> 
    <AppenderRef ref="solrEventLogger" /> 
    </Logger> 
    <Root level="warn"> 
    <AppenderRef ref="tomcatLog"/> 
    </Root> 
</Loggers> 
</Configuration> 

回答

2

級別API指定允許配置級別和更具體級別的消息通過。因此,指定level = info,允許警告通過。