Skip to content

spring boot configuration logging.config not working in 2.25.0 #3808

@polarisGitHub

Description

@polarisGitHub

Description

My project is deployed using docker, and log4j.xml is placed in the configuration center instead of locally. Use logging.config=./conf/log4j2.xml to specify the configuration file

When using 2.24.3, log4j2 works normally, but when using 2.25.0, there is no log output.

log write configuration is load, but log4j not work.

I tried to compare it with version 2.24.3 and found that there might be a problem

2.25.0 lacks the setConfiguration call, which causes the loaded configuration to not take effect.

// 2.25.0
public void start(final Configuration config) {
    LOGGER.info("Starting {}[name={}] with configuration {}...", getClass().getSimpleName(), getName(), config);
    if (configLock.tryLock()) {
        try {
            if (this.isInitialized() || this.isStopped()) {
                setStarting();
                reconfigure(config);
                if (this.configuration.isShutdownHookEnabled()) {
                    setUpShutdownHook();
                }
                this.setStarted();
            }
        } finally {
            configLock.unlock();
        }
    }
    LOGGER.info("{}[name={}] started with configuration {}.", getClass().getSimpleName(), getName(), config);
}

// 2.24.3
public void start(final Configuration config) {
    LOGGER.info("Starting {}[name={}] with configuration {}...", getClass().getSimpleName(), getName(), config);
    if (configLock.tryLock()) {
        try {
            if (this.isInitialized() || this.isStopped()) {
                if (this.configuration.isShutdownHookEnabled()) {
                    setUpShutdownHook();
                }
                this.setStarted();
            }
        } finally {
            configLock.unlock();
        }
    }
    setConfiguration(config);
    LOGGER.info("{}[name={}] started with configuration {}.", getClass().getSimpleName(), getName(), config);
}

Version:
spring boot version: 2.7.18
log4j2 version: 2.25.0

Operating system: linux

JDK: jdk17

Logs

2025-07-08T07:42:04.861760Z main DEBUG Loaded configuration from /Users/xxx/src/zzz/conf/log4j2.xml
2025-07-08T07:42:06.402691Z main INFO Starting LoggerContext[name=76ed5528] with configuration XmlConfiguration[location=/Users/xxx/src/zzz/conf/log4j2.xml, lastModified=2025-07-08T07:42:02.425Z]...
2025-07-08T07:42:06.403729Z main INFO LoggerContext[name=76ed5528] started with configuration XmlConfiguration[location=/Users/xxx/src/zzz/conf/log4j2.xml, lastModified=2025-07-08T07:42:02.425Z].
.

Reproduction

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicatePull requests or issues with another instance elsewhere

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions