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 "Daniel Fowler (JIRA)" <ji...@apache.org> on 2015/02/24 23:16:04 UTC

[jira] [Created] (LOG4J2-960) Custom ConfigurationFactory that uses no configuration file will never be used

Daniel Fowler created LOG4J2-960:
------------------------------------

             Summary: Custom ConfigurationFactory that uses no configuration file will never be used
                 Key: LOG4J2-960
                 URL: https://issues.apache.org/jira/browse/LOG4J2-960
             Project: Log4j 2
          Issue Type: Bug
          Components: Configurators
    Affects Versions: 2.1
         Environment: log4j 2.1, Java 1.7
            Reporter: Daniel Fowler


If I create a custom ConfigurationFactory that accepts all configuration files (getSupportedTypes() returns String[] {"*"}) and do not specify a configuration file via the System property 'log4j.configurationFile' then the ConfigurationFactory that I specify will never be used.

In org/apache/logging/log4j/core/config/ConfigurationFactory.java in method 'public Configuration getConfiguration(final String name, final URI configLocation)' configLocation will be null and when trying to load the configuration file System property for String config it will be null.

The execution in the method will then skip down to these lines:
Configuration config = getConfiguration(true, name);
             if (config == null) {

In this case the custom configuration factory will not be used because in the method 'private Configuration getConfiguration(final boolean isTest, final String name)' skips over all configuration factories that return 'null' or 'String[] {"*"}' for factory.getSupportedTypes().  Therefore it will return null and eventually the Default configuration will be used.

Therefore it is impossible to use a custom ConfigurationFactory without specifying the the System property 'log4j.configurationFile' which the documentation (http://logging.apache.org/log4j/2.0/manual/configuration.html) seems to imply should be programmatically permissible.





--
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