Skip to content

Incorrect warning about message factories mismatch #3461

@kostya-sh

Description

@kostya-sh

Description

It appears that AbstractLogger.checkMessageFactory expects the default message factory to be ParameterizedMessageFactory (

} else if (messageFactory == null && !loggerMessageFactory.getClass().equals(DEFAULT_MESSAGE_FACTORY_CLASS)) {
). However if thread locals are enabled the default message factory is ReusableMessageFactory (
private static MessageFactory getEffectiveMessageFactory(final MessageFactory messageFactory) {
)

Configuration

Version: 2.24.0

Operating system: [OS and version]

JDK: 17

Logs

2025-02-12T10:31:17.559492800Z main WARN The Logger Log4JMessageFactoryWarning was created with the message factory org.apache.logging.log4j.message.ReusableMessageFactory@32ee6fee 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.

Reproduction

Log4j configuration should have status="info" enabled.

import org.apache.logging.log4j.LogManager;

public class Log4JMessageFactoryWarning {

	public static void main(String[] args) {
		LogManager.getLogger(Log4JMessageFactoryWarning.class);
		LogManager.getLogger(Log4JMessageFactoryWarning.class);
	}
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions