Log4j 2.6.x and log4j 2.15 's xml configuration seems incompatible

Viewed 299

To upgrade my log4j2 from 2.6.2 to 2.15.0, I simply uses maven build to change the pom.xml log4j-core and log4j-api 's version. However, once I have deployed the java application to tomcat. Log4j 2.15.0 doesn't log to the specific file but catalina.out only. When I fallback to the previous 2.6.x without changing anything, things worked as expected. The log4j.xml I have is as shown below and The way that I get the logManager in Java is just

private static Logger log = LogManager.getLogger("Logger");

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
         <RollingFile name="errorLogging" fileName="/opt/app/tomcat8/logs/test.log"
                 filePattern="/opt/app/tomcat8/logs/test.log.%d{yyyy-MM-dd}">
              <PatternLayout>
                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
              </PatternLayout>
              <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
              </Policies>
        </RollingFile>
    </Appenders>
    
    <Loggers>
        <Root level="info" additivity="false">
        </Root>
        <Logger name="Logger" level="info">
            <AppenderRef ref="errorLogging" level="info"/>
        </Logger>
    </Loggers>
    
</Configuration>
0 Answers
Related