2016-01-20 68 views
1

我想使用Flume Appender屬性log4j2。但運行程序時會獲得以下錯誤。log4j2-錯誤Appenders包含無效的元素或屬性「Flume」

2016-01-20 16:36:42,436 main ERROR Appenders contains an invalid element or attribute "Flume" 
    2016-01-20 16:36:42,436 main ERROR Appenders contains an invalid element or attribute "Flume" 
    2016-01-20 16:36:42,446 main ERROR Unable to locate appender "eventLogger" for logger config "root" 
    2016-01-20 16:36:42,446 main ERROR Unable to locate appender "eventLogger" for logger config "root" 

log4j.xml文件的文件是:

<?xml version="1.0" encoding="UTF-8"?> 
<Configuration status="WARN"> 
    <Appenders> 
    <Console name="Console" target="SYSTEM_OUT"> 
     <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> 
    </Console> 
    <Flume name="eventLogger" compress="false" type="Avro"> 
     <Agent host="192.168.8.50" port="41414"/> 
    </Flume> 
    </Appenders> 
    <Loggers> 
    <Root level="info"> 
     <AppenderRef ref="Console" /> 
     <AppenderRef ref="eventLogger" /> 
    </Root> 
    </Loggers> 
</Configuration> 

而在代碼名爲.java

LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false); 
File file = new File("src/log4j2.xml"); 
context.setConfigLocation(file.toURI()); 

我怎樣才能找出問題。可能被log4j2沒有按」 t正常工作。

回答

0

你的classpath中有log4j flume jar嗎?如果您將狀態設置爲調試,則應該會看到更多信息。

相關問題