log4j2- ERROR Appenders contains an invalid element or attribute "Flume"
Asked Answered
U

2

6

I am trying to use Flume Appender Properties of log4j2 .But the following errors are obtained when run the program .

  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"

The log4j.xml file is:

<?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>

And in .java code

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

How I can figure out the problem .May be log4j2 doesn't work properly .

Urbano answered 20/1, 2016 at 10:42 Comment(0)
W
7

I encountered a similar situation, even Appender element is not recognized under Appenders. the fix is to add strict = "true" in configuration, like below

Configuration status="WARN" strict="true"

Willianwillie answered 19/7, 2019 at 19:31 Comment(0)
P
1

Do you have the log4j flume jar in your classpath? If you set status to debug you should see more information.

Polytrophic answered 20/1, 2016 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.