You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2015/10/06 16:33:26 UTC

[jira] [Resolved] (LOG4J2-1153) Unable to define only rootLogger in a properties file.

     [ https://issues.apache.org/jira/browse/LOG4J2-1153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma resolved LOG4J2-1153.
---------------------------------
       Resolution: Fixed
    Fix Version/s: 2.4.1

Thank you for reporting this issue!

Looks like this slipped through the cracks because we only tested configurations that had both a root logger and one or more named loggers.

Fixed in master in commit 9f924f10.
Please verify and close.

> Unable to define only rootLogger in a properties file.
> ------------------------------------------------------
>
>                 Key: LOG4J2-1153
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1153
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.4
>         Environment: Linux Ubuntu 14.04; Java 1.8; Log4j-2.4
>            Reporter: ElMehdi TAHRI
>            Assignee: Remko Popma
>              Labels: logger, nullpointerexception, properties, root, xml
>             Fix For: 2.4.1
>
>
> 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 :
> {code:xml}
>   <Loggers>
>       <Root level="info">
>          <AppenderRef ref="ConsoleAppender"/>
>      </Root>
>   </Loggers>
> {code}
> And this is a preview of the properties file :
> {code}
> rootLogger.level = info
> rootLogger.appenderRefs = console
> rootLogger.appenderRef.console.ref = ConsoleAppender
> {code}
> This configuration throw a null pointer exception :
> {noformat}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)
> {noformat}
> 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 ? 
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org