Skip to content

2.24.0 status logger warns about message factory mismatch #2933

@arlampin

Description

@arlampin

Description

After updating to 2.24.0 from 2.23.1, the status logger logs the following warning:

2024-09-09T12:14:29.525247Z main WARN The Logger eu.lampinen.log4j2test.Test was created with the message factory org.apache.logging.log4j.message.ReusableMessageFactory@3d680b5a and is now requested with a null message factory (defaults to org.apache.logging.log4j.message.ParameterizedMessageFactory), which may create log events with unexpected formatting.

The whole sample code is below

import org.apache.logging.log4j.LogManager;

public class Test {

    static {
        System.setProperty("log4j2.statusLoggerLevel", "WARN");
    }

    public static void main(String[] args) {
        LogManager.getLogger(Test.class).error("Hello {}", "world!");
        LogManager.getLogger(Test.class).error("Hello {}", "world!");
    }

}

I think this is caused by a mismatch between

  • AbstractLogger.checkMessageFactory, which uses constant DEFAULT_MESSAGE_FACTORY_CLASS
  • Logger.getEffectiveMessageFactory, which uses either ReusableMessageFactory or ParameterizedMessageFactory depending on Constants.ENABLE_THREADLOCALS.

Setting log4j2.enable.threadlocals=false will disable the warning.

Configuration

Version: 2.24.0

JDK: Azul 21

Logs

2.23.1

ERROR - Hello world!
ERROR - Hello world!

2.24.0

ERROR - Hello world!
2024-09-09T12:16:29.792995Z main WARN The Logger eu.lampinen.log4j2test.Test was created with the message factory org.apache.logging.log4j.message.ReusableMessageFactory@49d904ec and is now requested with a null message factory (defaults to org.apache.logging.log4j.message.ParameterizedMessageFactory), which may create log events with unexpected formatting.
ERROR - Hello world!

Reproduction

See above

Metadata

Metadata

Assignees

Labels

apiAffects the public APIbugIncorrect, unexpected, or unintended behavior of existing code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions