Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4
-
Linux Ubuntu 14.04; Java 1.8; Log4j-2.4
Description
I've changed the version of log4j2 from 2.3 to 2.4 in order to load the configuration via properties file. So i have converted the xml file, that defines only <Root> in <Loggers> element, into a properties file.
This is a preview of the xml file :
<Loggers> <Root level="info"> <AppenderRef ref="ConsoleAppender"/> </Root> </Loggers>
And this is a preview of the properties file :
rootLogger.level = info rootLogger.appenderRefs = console rootLogger.appenderRef.console.ref = ConsoleAppender
This configuration throw a null pointer exception :
Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.NullPointerException at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:132) at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:44) at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:491) at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:461) at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:257) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:493) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:510) at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:199) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:146) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:264) at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59) at org.apache.log4j.Logger.getLogger(Logger.java:41)
In order to make this configuration work, i had to add the loggers component and fill the identifiers. My question is why in xml file we can define only a root logger and it works fine, and in a properties file it does not work ?