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:19:05 UTC
[logging-log4j2] branch release-2.x 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 release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new dfced48 LOG4J2-2266 - Load PropertySources from any accessible ClassLoader and handle any exceptions
dfced48 is described below
commit dfced487bdb422c56334922411e10447bdb64969
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Wed Jan 30 19:53:53 2019 -0700
LOG4J2-2266 - Load PropertySources from any accessible ClassLoader and handle any exceptions
---
.../org/apache/logging/log4j/util/PropertiesUtil.java | 15 ++++++++++++---
src/changes/changes.xml | 3 +++
2 files changed, 15 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 334fd7b..c4104f7 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,18 @@ 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 f5964d7..071b1df 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -31,6 +31,9 @@
- "remove" - Removed
-->
<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>