Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid log4j2 configuration debug messages to appear

I'm trying to use log4j2 for the first time. It is logging according to my configuration except it is also outputting something like configuration debug messages to console:

2013-08-07 19:36:50,870 DEBUG Generated plugins in 0.000029274 seconds
2013-08-07 19:36:50,871 DEBUG Generated plugins in 0.000028703 seconds
2013-08-07 19:36:50,871 DEBUG Generated plugins in 0.000022613 seconds
2013-08-07 19:36:50,872 DEBUG Generated plugins in 0.000017492 seconds
2013-08-07 19:36:50,872 DEBUG Generated plugins in 0.000017009 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000025645 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000017140 seconds
2013-08-07 19:36:50,873 DEBUG Generated plugins in 0.000017438 seconds
2013-08-07 19:36:50,874 DEBUG Generated plugins in 0.000018848 seconds
2013-08-07 19:36:50,874 DEBUG Generated plugins in 0.000018203 seconds
2013-08-07 19:36:50,875 DEBUG Generated plugins in 0.000017775 seconds
2013-08-07 19:36:50,875 DEBUG Generated plugins in 0.000018104 seconds
2013-08-07 19:36:50,876 DEBUG Generated plugins in 0.000017015 seconds
2013-08-07 19:36:50,876 DEBUG Generated plugins in 0.000018079 seconds
2013-08-07 19:36:50,890 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{HH:mm:ss.SSS} %-5level %msg%n", Configuration(.../conf/preprocessor.log4j2.xml), null, charset="null", suppressExceptions="null")
2013-08-07 19:36:50,890 DEBUG Generated plugins in 0.000032718 seconds
2013-08-07 19:36:50,893 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{HH:mm:ss.SSS} %-5level %msg%n), null, target="SYSTEM_OUT", name="Console", follow="null", suppressExceptions="null")
2013-08-07 19:36:50,894 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n", Configuration(.../conf/preprocessor.log4j2.xml), null, charset="null", suppressExceptions="null")
2013-08-07 19:36:50,895 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy for element SizeBasedTriggeringPolicy with params(size="10 MB")
2013-08-07 19:36:50,897 DEBUG Calling createPolicy on class org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy for element Policies with params(policies={SizeBasedTriggeringPolicy(size=10485760)})
2013-08-07 19:36:50,900 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile with params(fileName="logs/preprocessor.log", filePattern="logs/preprocessor-%d{yyyy-MM-dd-HH}-%i.log.gz", append="null", name="RollingFileAll", bufferedIO="null", immediateFlush="null", Policies(CompositeTriggeringPolicy{SizeBasedTriggeringPolicy(size=10485760)}), null, PatternLayout(%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n), null, suppressExceptions="null", advertise="null", advertiseURI="null", Configuration(..../conf/preprocessor.log4j2.xml))
2013-08-07 19:36:50,902 DEBUG Starting RollingFileManager logs/preprocessor.log
2013-08-07 19:36:50,904 DEBUG Generated plugins in 0.000022500 seconds
2013-08-07 19:36:50,906 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={Console, RollingFileAll})
2013-08-07 19:36:50,906 DEBUG Generated plugins in 0.000019671 seconds
2013-08-07 19:36:50,908 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="WARN", null)
2013-08-07 19:36:50,908 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="RollingFileAll", level="null", null)
2013-08-07 19:36:50,910 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="false", level="ERROR", name="eventLogger", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@22b27cca, org.apache.logging.log4j.core.config.AppenderRef@741ec391}, properties={}, Configuration(.../conf/preprocessor.log4j2.xml), null)
2013-08-07 19:36:50,912 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="INFO", null)
2013-08-07 19:36:50,913 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="RollingFileAll", level="null", null)
2013-08-07 19:36:50,915 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="DEBUG", includeLocation="null", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@72607cad, org.apache.logging.log4j.core.config.AppenderRef@1c997c85}, properties={}, Configuration(.../preprocessor.log4j2.xml), null)
2013-08-07 19:36:50,916 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={eventLogger, root})

My configuration file preprocessor.log4j2.xml looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration status="DEBUG">
    <appenders>

        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %msg%n" />
        </Console>

        <RollingFile name="RollingFileAll" fileName="logs/preprocessor.log"
            filePattern="logs/preprocessor-%d{yyyy-MM-dd-HH}-%i.log.gz">
            <PatternLayout pattern="%d{MM-dd HH:mm:ss.SSS} %-5level %msg%n" />
            <Policies>
                <SizeBasedTriggeringPolicy size="10 MB" />
            </Policies>
        </RollingFile>

    </appenders>
    <loggers>   
        <root level="DEBUG">
            <appender-ref ref="Console" level="INFO" />
            <appender-ref ref="RollingFileAll" />
        </root>
    </loggers>
</configuration>

And this is how I configure (I know about autoconfigure) the log4j2 from within java:

File file = new File(LOG4J2_CONF_FILE);
Configurator.initialize("preprocessor", null, file.toURI());

I have tried adding EventLogger logger and disabling its output, but it did not helped. Do you have an idea how to avoid this configuration debug messages to appear?

Thank you in advance for any tips.

like image 466
V-tech Avatar asked Aug 08 '13 09:08

V-tech


1 Answers

just remove status="DEBUG" from the configuration tag

like image 195
chaosguru Avatar answered Dec 05 '22 00:12

chaosguru