Nutty Noru
Nutty Noru

Reputation: 51

How do I correct this error while appending to a log file using log4j2?

Error report says:

2016-06-17 09:37:14,122 main ERROR Error processing element Appender ([Appenders: null]): CLASS_NOT_FOUND
2016-06-17 09:37:14,168 main ERROR Unable to locate appender "Console" for logger config "root"

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
  <Appenders>
  <Appender type="File" name="Console" fileName="C:\Users\raghi\Documents\NetBeansProjects\mdepth\JavaApplication3\build\classes\oo.txt">
  <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Appender>
  </Appenders>
  <Loggers>
    <Root level="error">
      <AppenderRef ref="Console"/>
    </Root>
    <Root level="info">
      <appender-ref ref="Console"/>
    </Root>
    <Root level="trace">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

It looks like we can't append this way to the log file. There is something wrong here. Please help me out on this instead of any downvotes.

Upvotes: 1

Views: 3208

Answers (1)

rgoers
rgoers

Reputation: 9141

You are using a mix of the strict syntax and non-strict syntax. You also have 3 root loggers but you can only have one. Please review http://logging.apache.org/log4j/2.x/manual/configuration.html

Upvotes: 1

Related Questions