logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ElMehdi TAHRI (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (LOG4J2-1153) Unable to define only rootLogger in a properties file.
Date Tue, 06 Oct 2015 15:04:26 GMT

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

ElMehdi TAHRI closed LOG4J2-1153.
---------------------------------

Works fine (y)	

> 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


Mime
View raw message