You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/10 21:31:56 UTC
[logging-log4j2] 02/03: Log4j 1.2 bridge missing OptionConverter.instantiateByKey(Properties, String, Class, Object).
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit b4de2991b00db942e9f78fe9131f28742dea279d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 10 16:31:41 2022 -0500
Log4j 1.2 bridge missing OptionConverter.instantiateByKey(Properties,
String, Class, Object).
---
.../main/java/org/apache/log4j/helpers/OptionConverter.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java
index b55a015..5fe6043 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java
@@ -221,6 +221,18 @@ public class OptionConverter {
return defaultValue;
}
+ public static Object instantiateByKey(Properties props, String key, Class superClass, Object defaultValue) {
+
+ // Get the value of the property in string form
+ String className = findAndSubst(key, props);
+ if (className == null) {
+ LogLog.error("Could not find value for key " + key);
+ return defaultValue;
+ }
+ // Trim className to avoid trailing spaces that cause problems.
+ return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue);
+ }
+
/**
* Configure log4j given an {@link InputStream}.
* <p>