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 2017/01/17 05:47:54 UTC
logging-log4j2 git commit: LOG4J2-1243 - Enable substitution in
variables
Repository: logging-log4j2
Updated Branches:
refs/heads/master 2a49f555a -> c29526014
LOG4J2-1243 - Enable substitution in variables
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c2952601
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c2952601
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c2952601
Branch: refs/heads/master
Commit: c29526014207b3937b70a91c6572c40b6704262d
Parents: 2a49f55
Author: Ralph Goers <ra...@dslextreme.com>
Authored: Mon Jan 16 22:47:48 2017 -0700
Committer: Ralph Goers <ra...@dslextreme.com>
Committed: Mon Jan 16 22:47:48 2017 -0700
----------------------------------------------------------------------
.../logging/log4j/core/lookup/StrSubstitutor.java | 14 ++++----------
log4j-core/src/test/resources/log4j-loggerprops.xml | 2 +-
2 files changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c2952601/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
index 3e91951..5fd9e44 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/StrSubstitutor.java
@@ -185,7 +185,7 @@ public class StrSubstitutor implements ConfigurationAware {
/**
* The flag whether substitution in variable names is enabled.
*/
- private boolean enableSubstitutionInVariables;
+ private boolean enableSubstitutionInVariables = true;
/**
* The currently active Configuration for use by ConfigurationAware StrLookup implementations.
*/
@@ -940,7 +940,7 @@ public class StrSubstitutor implements ConfigurationAware {
varNameExpr = bufName.toString();
}
pos += endMatchLen;
- int endPos = pos;
+ final int endPos = pos;
String varName = varNameExpr;
String varDefaultValue = null;
@@ -956,13 +956,7 @@ public class StrSubstitutor implements ConfigurationAware {
}
if ((valueDelimiterMatchLen = valueDelimiterMatcher.isMatch(varNameExprChars, i)) != 0) {
varName = varNameExpr.substring(0, i);
- varDefaultValue = variableResolver.lookup(varNameExpr.substring(i + valueDelimiterMatchLen));
- if (varDefaultValue != null) {
- ++endPos;
- }
- if (varDefaultValue == null) {
- varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
- }
+ varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
break;
}
}
@@ -1335,7 +1329,7 @@ public class StrSubstitutor implements ConfigurationAware {
* Sets a flag whether substitution is done in variable names. If set to
* <b>true</b>, the names of variables can contain other variables which are
* processed first before the original variable is evaluated, e.g.
- * <code>${jre-${java.version}}</code>. The default value is <b>false</b>.
+ * <code>${jre-${java.version}}</code>. The default value is <b>true</b>.
*
* @param enableSubstitutionInVariables the new value of the flag
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c2952601/log4j-core/src/test/resources/log4j-loggerprops.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j-loggerprops.xml b/log4j-core/src/test/resources/log4j-loggerprops.xml
index f327029..bdd13cd 100644
--- a/log4j-core/src/test/resources/log4j-loggerprops.xml
+++ b/log4j-core/src/test/resources/log4j-loggerprops.xml
@@ -20,7 +20,7 @@
<Property name="test2">test2default</Property>
<Property name="attribKey" value="attribValue" />
<Property name="duplicateKey" value="attribValue">nodeValue</Property>
- <Property name="test5">${sys:test3:-${sys:test}}</Property>
+ <Property name="test5">${sys:test:-${sys:test2}}</Property>
</Properties>
<Appenders>
<List name="List">