You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/07/25 14:54:29 UTC

logging-log4j2 git commit: LOG4J2-1313 Properties declared in configuration can now have their value either in the element body or in an attribute named "value".

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 6b2573a13 -> 0c52e34d9


LOG4J2-1313 Properties declared in configuration can now have their value either in the element body or in an attribute named "value".


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0c52e34d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0c52e34d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0c52e34d

Branch: refs/heads/master
Commit: 0c52e34d95f0b1f6093f21fe4c98ba530f337ef0
Parents: 6b2573a
Author: rpopma <rp...@apache.org>
Authored: Mon Jul 25 23:54:18 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Mon Jul 25 23:54:18 2016 +0900

----------------------------------------------------------------------
 .../core/config/plugins/visitors/PluginValueVisitor.java     | 5 +++--
 .../logging/log4j/core/config/xml/XmlLoggerPropsTest.java    | 8 ++++++--
 log4j-core/src/test/resources/log4j-loggerprops.xml          | 4 +++-
 src/changes/changes.xml                                      | 3 +++
 4 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c52e34d/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
index 5ec53da..82dc20d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.java
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.Node;
 import org.apache.logging.log4j.core.config.plugins.PluginValue;
 import org.apache.logging.log4j.util.StringBuilders;
+import org.apache.logging.log4j.util.Strings;
 
 /**
  * PluginVisitor implementation for {@link PluginValue}.
@@ -35,8 +36,8 @@ public class PluginValueVisitor extends AbstractPluginVisitor<PluginValue> {
     public Object visit(final Configuration configuration, final Node node, final LogEvent event,
                         final StringBuilder log) {
         final String name = this.annotation.value();
-        final String rawValue = node.getValue() != null ? node.getValue() :
-            removeAttributeValue(node.getAttributes(), "value");
+        final String rawValue = Strings.isNotEmpty(node.getValue()) ? node.getValue() :
+                removeAttributeValue(node.getAttributes(), "value");
         final String value = this.substitutor.replace(event, rawValue);
         StringBuilders.appendKeyDqValue(log, name, value);
         return value;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c52e34d/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
index 094defa..01bd086 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
@@ -66,14 +66,18 @@ public class XmlLoggerPropsTest {
                 containsString("phrasex=****"),
                 containsString("test=test"),
                 containsString("test2=test2default"),
-                containsString("test3=Unknown")
+                containsString("test3=Unknown"),
+                containsString("attribKey=attribValue"),
+                containsString("duplicateKey=nodeValue")
             ));
             assertThat(events.get(1), allOf(
                 containsString("user="),
                 containsString("phrasex=****"),
                 containsString("test=test"),
                 containsString("test2=test2default"),
-                containsString("test3=Unknown")
+                containsString("test3=Unknown"),
+                containsString("attribKey=attribValue"),
+                containsString("duplicateKey=nodeValue")
             ));
         } finally {
             System.clearProperty("test");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c52e34d/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 daa7439..84e4fea 100644
--- a/log4j-core/src/test/resources/log4j-loggerprops.xml
+++ b/log4j-core/src/test/resources/log4j-loggerprops.xml
@@ -18,10 +18,12 @@
 <Configuration status="OFF" strict="false" name="DSI">
   <Properties>
      <Property name="test2">test2default</Property>
+     <Property name="attribKey" value="attribValue" />
+     <Property name="duplicateKey" value="attribValue">nodeValue</Property>
   </Properties>
   <Appenders>
     <List name="List">
-        <PatternLayout pattern="[%-5level] %c{1.} user=%X{user} phrasex=%X{phrasex} test=%X{test} test2=$${sys:test2} test3=$${sys:test3:-Unknown} %msg%n" />
+        <PatternLayout pattern="[%-5level] %c{1.} user=%X{user} phrasex=%X{phrasex} test=%X{test} test2=$${sys:test2} test3=$${sys:test3:-Unknown} attribKey=$${attribKey} duplicateKey=$${duplicateKey}%msg%n" />
     </List>
   </Appenders>
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c52e34d/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1b0dcc6..d0032c6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
   </properties>
   <body>
     <release version="2.7.0" date="2016-MM-DD" description="GA Release 2.7.0">
+      <action issue="LOG4J2-1313" dev="rpopma" type="fix" due-to="Philipp Knobel">
+        Properties declared in configuration can now have their value either in the element body or in an attribute named "value".
+      </action>
       <action issue="LOG4J2-1472" dev="ggregory" type="add" due-to="Gary Gregory">
         Make org.apache.logging.log4j.core.LoggerContext implement Closeable.
       </action>