简体   繁体   中英

Log4j2 tomcat configuration issue during Spring startup

I am having an issue with my recently upgraded log4j. Moved to log4j2, and I am seeing outputs from Spring attaching URL path handlers at the INFO level. However I am setting my root logger to error.

Here is the configuration

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" xmlns="http://logging.apache.org/log4j/2.0/config">
    <Properties>
        <Property name="LOG_DIR">logs</Property>
        <Property name="ARCHIVE">${LOG_DIR}</Property>
        <Property name="LOG_PREFIX">logname-</Property>
        <Property name="FILE_PATTERN">%d{ISO8601}\t%r\t%t\t%-5p\t%c{1}\t%m%n</Property>
        <Property name="CONSOLE_PATTERN">[%d{ISO8601}|%-5p|%c{1}|%M|%L] %m%n</Property>
    </Properties>
    <Appenders>
        <File name="FILE" fileName="logname.log" append="true">
            <PatternLayout pattern="${FILEPATTERN}" />
        </File>
        <RollingFile name="fileWriter" fileName="${LOG_DIR}/${LOG_PREFIX}.log" filePattern="${ARCHIVE}/${LOG_PREFIX}-%d{yyyy-MM-dd-hh-mm}.log" immediateFlush="false">
            <PatternLayout pattern="${FILE_PATTERN}" />
            <TimeBasedTriggeringPolicy/>
        </RollingFile>

        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="${CONSOLE_PATTERN}" />
        </Console>
        <Async name="Async-File">
            <AppenderRef ref="FILE" />
        </Async>
        <Async name="Async-Console">
            <AppenderRef ref="STDOUT" />
        </Async>
    </Appenders>
    <Loggers>
        <Root>
            <AppenderRef ref="Async-Console" level="error" />
            <AppenderRef ref="Async-File" level="error" />
        </Root>
    </Loggers>
</Configuration>

And the tomcat output on startup

Nov 01, 2015 5:19:34 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/universal/applyTemplate/] onto handler 'RESTTemplate'

There are a couple hundred lines of this startup but I figured one would be sufficient. Is the ROOT logger not being overridden in this case?

Tomcat version is 7.55 as well.

The output doesn't match the pattern your configuration must not be in use. Did you add log4j-web to your application? Did you follow the instructions at http://logging.apache.org/log4j/2.x/manual/webapp.html ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM