-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
apiAffects the public APIAffects the public APIbugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code
Milestone
Description
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 constantDEFAULT_MESSAGE_FACTORY_CLASS
Logger.getEffectiveMessageFactory
, which uses eitherReusableMessageFactory
orParameterizedMessageFactory
depending onConstants.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
ianbrandt and paulchen
Metadata
Metadata
Assignees
Labels
apiAffects the public APIAffects the public APIbugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing code