Skip to content

Unwanted logging "Starting configuration...", "Start watching for changes to...", etc) after update. #3566

@Fariusz

Description

@Fariusz

Description

Hello, I have problem with log4j after update.
Can I ask for a help?

After I've updated dependencies:

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>

from version 2.22.1 to version 2.24.3 it started to log unwanted logging lines (that was not present before):

Starting configuration XmlConfiguration[location=… , lastModified=…]...
Start watching for changes to … every 0 seconds
Configuration XmlConfiguration[location=… , lastModified=…] started.
Stopping configuration org.apache.logging.log4j.core.config.DefaultConfiguration@…
Configuration org.apache.logging.log4j.core.config.DefaultConfiguration@… stopped.
Stopping configuration XmlConfiguration[location=… , lastModified=…]...
Configuration XmlConfiguration[location=… , lastModified=…] stopped.

Configuration

Version: 2.24.3

Operating system: Redhat 8

JDK: OpenJDK 17

Log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" strict="true" name="XMLConfigForTest">
    <Filter type="ThresholdFilter" level="debug"/>

    <Appenders>
        <Appender type="Console" name="STDOUT">
            <Layout type="PatternLayout" pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
        </Appender>
        <Appender type="RollingFile" name="fileAppender" fileName="/.../.../.../.../logs/javaApp.log"
                  filePattern="/.../.../.../.../logs/javaApp%d{yyyy-MM-dd_HHmmss}.log" filePermissions="rw-rw-r--">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
            <Policies>
                <SizeBasedTriggeringPolicy size="10 MB" />
            </Policies>
        </Appender>
    </Appenders>

    <Loggers>
        <Root level="info">
            <AppenderRef ref="fileAppender" />
        </Root>
        <Logger name="org.springframework" level="WARN" additivity="false">
            <Appender-ref ref="fileAppender" level="WARN" />
        </Logger>
        <Logger name="XYZ.ABC" level="INFO" additivity="false">
            <Appender-ref ref="fileAppender" level="INFO" />
        </Logger>
        
    </Loggers>
</Configuration>
#! /bin/bash

javaApps_modules=/.../.../.../.../modules
cd $javaApps_modules/${project.artifactId}
/usr/bin/java -Xmx1500m -Dlog4j.configurationFile=./log4j2.xml -jar ${project.artifactId}.jar $@

Logs

2025-03-21T10:17:03.408045086Z main INFO Starting configuration XmlConfiguration[location=/.../.../.../JavaApp/modules/JavaApp/log4j2.xml, lastModified=2025-03-21T10:01:49.648Z]...
2025-03-21T10:17:03.408531502Z main INFO Start watching for changes to /.../.../.../JavaApp/modules/JavaApp/log4j2.xml every 0 seconds
2025-03-21T10:17:03.408943877Z main INFO Configuration XmlConfiguration[location=/.../.../.../.../modules/JavaApp/log4j2.xml, lastModified=2025-03-21T10:01:49.648Z] started.
2025-03-21T10:17:03.409866752Z main INFO Stopping configuration org.apache.logging.log4j.core.config.DefaultConfiguration@1da51a35...
2025-03-21T10:17:03.410062127Z main INFO Configuration org.apache.logging.log4j.core.config.DefaultConfiguration@1da51a35 stopped.
2025-03-21T10:17:03.829151377Z pool-1-thread-1 INFO Stopping configuration XmlConfiguration[location=/.../.../.../.../modules/JavaApp/log4j2.xml, lastModified=2025-03-21T10:01:49.648Z]...
2025-03-21T10:17:03.829701752Z pool-1-thread-1 INFO Configuration XmlConfiguration[location=/.../.../.../.../modules/JavaApp/log4j2.xml, lastModified=2025-03-21T10:01:49.648Z] stopped.

Reproduction

[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]
Everytime jar is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions