[
https://issues.apache.org/jira/browse/LOG4J2-3063?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17314801#comment-17314801
]
Anand Beh commented on LOG4J2-3063:
-----------------------------------
While configuring log4j via system properties, it seemed that the new versions
of the properties from log4j 2.10+ were not working. For example the following:
{code:java}
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
-Dlog4j2.configurationFile=log4j2-debug.xml
-Dlog4j2.asyncLoggerWaitStrategy=sleep
{code}
did not use async loggers and did not use the specified configuration file.
This was tracked down to a difference in running on the class-path versus the
module-path. On the module-path, the new property names do not have an effect,
but they do function on the class-path.
A reproducer is here: [https://github.com/A248/Log4j2-3063] . Running "/run.sh
classpath" yields the expected result with the configuration file used and
async logging enabled, whereas "/run.sh modulepath" does not.
Based on debugging, it was determined that PropertiesUtil.Environment was
loading 3 PropertySource implementations on the classpath -
PropertyFilePropertySource the default plus EnvironmentPropertySource and
SystemPropertiesPropertySource from the ServiceLoader. On the modulepath, only
the PropertyFilePropertySource is added to PropertiesUtil.Environment.
This is most likely caused by the missing provides directives which were
committed to the module-info here:
[https://github.com/apache/logging-log4j2/commit/720e78dbaa815c8838e8353a53c22817a90587b8#diff-cddb1581dcb09258fcfc0e016bda6a97236d20a6e34477659f658ffad49fccaf]
ServiceLoader.load(Class, ClassLoader) specifies that services are located,
first through named modules based on provides directives, and second through
automatic modules based on META-INF/services. The second stage, loading
services through META-INF/services, does not load any services from named
modules.
When log4j2 is on the module path it is a named module and thus needs these
provides directives. It is good to see that this issue is (probably?) already
fixed.
> Missing provides directives in module-info cause system properties to not
> accept post log4j 2.10 normalized versions
> --------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3063
> URL: https://issues.apache.org/jira/browse/LOG4J2-3063
> Project: Log4j 2
> Issue Type: Bug
> Reporter: Anand Beh
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)