You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "aitor moragas (Jira)" <ji...@apache.org> on 2022/01/10 21:39:00 UTC

[jira] [Comment Edited] (LOG4J2-3243) Property log4j.configurationFile incorrectly documented, log4j.configuration missing

    [ https://issues.apache.org/jira/browse/LOG4J2-3243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17472323#comment-17472323 ] 

aitor moragas edited comment on LOG4J2-3243 at 1/10/22, 9:38 PM:
-----------------------------------------------------------------

In the context of a migration from log4j v1 to log4j v2 we have switched from using *-Dlog4j.configuration* to *-Dlog4j2.configurationFile* and we have noticed that the property *log4j2.configurationFile* is not being read by the {+}ConfigurationFactory{+}. Only the property *log4j.configurationFile* ([source code|https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java])

Debugging our application and several cases we have found that:
{quote}//lines 95 to 100 in ConfigurationFactory.java

CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";

LOG4J1_CONFIGURATION_FILE_PROPERTY = "log4j.configuration";

LOG4J1_EXPERIMENTAL = "log4j1.compatibility";
{quote}
Then, in lines 394 to 533 in method getConfiguration:
 - if log4j2.configurationFile is provided, it is *not* taken into account.
 - if log4j.configurationFile is provided, it *is* taken into account.
 - if log4j.configurationFile is not provided, it attempts to *look for* a log4j v1 configuration file
 - if no configuration can be found, it attempts to *look for* a log4j experimental configuration file.

 

I believe this might help explain the issue reported here, as well as https://issues.apache.org/jira/browse/LOG4J2-3193  (an apparent issue of precedences set in the wrong order) and https://issues.apache.org/jira/browse/LOG4J2-3078 (documentation not accurate)

 

 


was (Author: JIRAUSER283345):
In the context of a migration from log4j v1 to log4j v2 we have switched from using *-Dlog4j.configuration* to *-Dlog4j2.configurationFile* and we have noticed that the property *log4j2.configurationFile* is not being read by the {+}ConfigurationFactory{+}. Only the property *log4j.configurationFile* ([source code|https://github.com/apache/logging-log4j2/blob/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java[)|https://github.com/apache/logging-log4j2/blame/f72100df0decc9bda96b4d769822c4e48b2848fc/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java])]

Debugging our application and several cases we have found that:


{quote}//lines 95 to 100 in ConfigurationFactory.java

CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";

LOG4J1_CONFIGURATION_FILE_PROPERTY = "log4j.configuration";

LOG4J1_EXPERIMENTAL = "log4j1.compatibility";
{quote}
Then, in lines 394 to 533 in method getConfiguration:

- if log4j2.configurationFile is provided, it is *not* taken into account.
- if log4j.configurationFile is provided, it *is* taken into account.
- if log4j.configurationFile is not provided, it attempts to *look for* a log4j v1 configuration file
- if no configuration can be found, it attempts to *look for* a log4j experimental configuration file.

 

I believe this might help explain the issue reported here, as well as https://issues.apache.org/jira/browse/LOG4J2-3193  (an apparent issue of precedences set in the wrong order) and https://issues.apache.org/jira/browse/LOG4J2-3078 (documentation not accurate)



 

 

> Property log4j.configurationFile incorrectly documented, log4j.configuration missing
> ------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3243
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3243
>             Project: Log4j 2
>          Issue Type: Documentation
>          Components: Configuration
>    Affects Versions: 2.16.0
>            Reporter: Sascha Volkenandt
>            Priority: Minor
>
> According to [1], Log4j looks for the system property log4j2.configurationFile. According to the sources of log4j-core-2.16.0 (ConfigurationFactory.java), the searched property is log4j.configurationFile. The other property does not seem to have any effect in recent versions.
> [1] [https://logging.apache.org/log4j/2.x/manual/configuration.html]
> Additionally, since 2.14.0 it looks for the property log4j.configuration (no "File"), which was also the property used by Log4j 1.x. As a consequence, logging stopped working in some of our systems after upgrading to 2.16.0 due to Log4Shell. Those systems are using both 1.x and 2.x so they have the property log4j.configuration set but not log4j.configurationFile, because we relied on the previous behaviour that if log4j.configurationFile is not set it looks in the classpath. I had to use a debugger to find out why it stopped working.
> It would be nice if that second property would also be mentioned in [1].



--
This message was sent by Atlassian Jira
(v8.20.1#820001)