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
Description
After updating to 2.24.0 from 2.23.1, the status logger logs the following warning:
The whole sample code is below
I think this is caused by a mismatch between
AbstractLogger.checkMessageFactory, which uses constantDEFAULT_MESSAGE_FACTORY_CLASSLogger.getEffectiveMessageFactory, which uses eitherReusableMessageFactoryorParameterizedMessageFactorydepending onConstants.ENABLE_THREADLOCALS.Setting
log4j2.enable.threadlocals=falsewill disable the warning.Configuration
Version: 2.24.0
JDK: Azul 21
Logs
2.23.1
2.24.0
Reproduction
See above