You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2019/01/31 03:18:52 UTC
[logging-log4j2] branch master updated: LOG4J2-2266 - Load
PropertySources from any accessible ClassLoader and handle any exceptions
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 0eee167 LOG4J2-2266 - Load PropertySources from any accessible ClassLoader and handle any exceptions
0eee167 is described below
commit 0eee16740007326988e2689e81e859ca03ae5bb6
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Wed Jan 30 20:18:35 2019 -0700
LOG4J2-2266 - Load PropertySources from any accessible ClassLoader and handle any exceptions
---
.../java/org/apache/logging/log4j/util/PropertiesUtil.java | 14 +++++++++++---
src/changes/changes.xml | 3 +++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index 2a9ff7f..b6e0172 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -316,9 +316,17 @@ public final class PropertiesUtil {
private Environment(final PropertySource propertySource) {
sources.add(propertySource);
- for (final PropertySource source : ServiceLoader.load(PropertySource.class, PropertySource.class.getClassLoader())) {
- sources.add(source);
- }
+ for (final ClassLoader classLoader : LoaderUtil.getClassLoaders()) {
+ try {
+ for (final PropertySource source : ServiceLoader.load(PropertySource.class, classLoader)) {
+ sources.add(source);
+ }
+ } catch (final Throwable ex) {
+ /* Don't log anything to the console. It may not be a problem that a PropertySource
+ * isn't accessible.
+ */
+ }
+ }
reload();
}
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1a5b09a..54d74b4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -354,6 +354,9 @@
</action>
</release>
<release version="2.11.2" date="2018-MM-DD" description="GA Release 2.11.2">
+ <action issue="LOG4J2-2266" dev="rgoers" type="fix">
+ Load PropertySources from any accessible ClassLoader. Hide any exceptions that may occur accessing a PropertySource.
+ </action>
<action issue="LOG4J2-1570" dev="rgoers" type="fix">
Logging with a lambda expression with a method call that also logs would cause logs within method call to reference line num and method name of the parent method.
</action>