Alireza Fattahi
Alireza Fattahi

Reputation: 45515

Log4j 2.6 warning for a null message factory

After upgrading to log4j2 version 2.6, I face these warnings:

2016-06-06 16:36:14,920 localhost-startStop-1 WARN The Logger foo.bar was created with the message factory org.apache.logging.log4j.spi.MessageFactory2Adapter@437958b6 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.

It was ok in version 2.5, any comments ?!

I see the log messages in appenders

Upvotes: 3

Views: 2065

Answers (2)

Remko Popma
Remko Popma

Reputation: 36784

This is a bug in the Log4j 2.6 release. It has been fixed (see https://issues.apache.org/jira/browse/LOG4J2-1407) and will be fixed in the upcoming 2.6.1 release (which is now being reviewed and should be live in ~48 hours).

It is not a real problem, the bug is that the warning is shown unnecessarily.

Upvotes: 5

roger zhan
roger zhan

Reputation: 142

mostly because the logger is created as a instance object, not static object, like this:

public class PropertiesConfigurationFactory {
    private final Log logger = LogFactory.getLog(getClass());
}

when create PropertiesConfigurationFactory again, logger is also created.

in LoggerContext it will get the created instance of logger

getLogger(name, null)

null is MessageFactory

so it will check the null with the old logger's messagefactory and it print out this warning. seems ok.

Upvotes: 0

Related Questions