You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2017/11/12 14:50:57 UTC

[1/5] logging-log4j2 git commit: Add documentation for log4j.formatMsgNoLookups

Repository: logging-log4j2
Updated Branches:
  refs/heads/master d5c42930d -> 69ddd6f9f


Add documentation for log4j.formatMsgNoLookups


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

Branch: refs/heads/master
Commit: 37912a7626fbec387ec54b87f4c9be768fe797c0
Parents: dd18e9b
Author: Carter Kozak <c4...@gmail.com>
Authored: Sat Nov 11 17:59:41 2017 -0500
Committer: Mikael Ståldal <mi...@staldal.nu>
Committed: Sun Nov 12 15:28:55 2017 +0100

----------------------------------------------------------------------
 src/site/xdoc/manual/configuration.xml.vm | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/37912a76/src/site/xdoc/manual/configuration.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
index 09e7ebc..e3042f4 100644
--- a/src/site/xdoc/manual/configuration.xml.vm
+++ b/src/site/xdoc/manual/configuration.xml.vm
@@ -2231,6 +2231,14 @@ public class AwesomeTest {
     <td>Prints a stacktrace to the <a href="#StatusMessages">status logger</a> at DEBUG level
     when the LoggerContext is started. For debug purposes.</td>
   </tr>
+  <tr>
+      <td><a name="formatMsgNoLookups"/>log4j.formatMsgNoLookups</td>
+      <td>FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS</td>
+      <td><a name="log4j.formatMsgNoLookups" />log4j.formatMsgNoLookups</td>
+      <td>false</td>
+      <td>Disables message pattern lookups globally when set to <tt>true</tt>.
+          This is equivalent to defining all message patterns using <tt>%m{nolookups}</tt>.</td>
+  </tr>
 </table>
 
         </subsection>


[2/5] logging-log4j2 git commit: LOG4J2-2109: Added "log4j.formatMsgNoLookups" global configuration

Posted by mi...@apache.org.
LOG4J2-2109: Added "log4j.formatMsgNoLookups" global configuration

This allows applications to globally disable message pattern
from looking up replacements without specifying "%m{nolookups}".


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

Branch: refs/heads/master
Commit: dd18e9b21009055e226daf5b233c92b6a17934ca
Parents: d5c4293
Author: Carter Kozak <c4...@gmail.com>
Authored: Thu Nov 9 08:32:14 2017 -0500
Committer: Mikael Ståldal <mi...@staldal.nu>
Committed: Sun Nov 12 15:28:55 2017 +0100

----------------------------------------------------------------------
 .../core/pattern/MessagePatternConverter.java   |  3 +-
 .../logging/log4j/core/util/Constants.java      |  9 +++++
 .../pattern/MessagePatternConverterTest.java    | 41 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd18e9b2/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
index 7b1d77e..92d75a2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/MessagePatternConverter.java
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.util.ArrayUtils;
+import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.core.util.Loader;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.MultiformatMessage;
@@ -56,7 +57,7 @@ public final class MessagePatternConverter extends LogEventPatternConverter {
         this.formats = options;
         this.config = config;
         final int noLookupsIdx = loadNoLookups(options);
-        this.noLookups = noLookupsIdx >= 0;
+        this.noLookups = Constants.FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS || noLookupsIdx >= 0;
         this.textRenderer = loadMessageRenderer(noLookupsIdx >= 0 ? ArrayUtils.remove(options, noLookupsIdx) : options);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd18e9b2/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
index aa8b74d..ef30491 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
@@ -55,6 +55,15 @@ public final class Constants {
             "log4j.format.msg.async", false);
 
     /**
+     * LOG4J2-2109 if {@code true}, MessagePatternConverter will always operate as though
+     * <pre>%m{nolookups}</pre> is configured.
+     *
+     * @since 2.10
+     */
+    public static final boolean FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS = PropertiesUtil.getProperties().getBooleanProperty(
+            "log4j.formatMsgNoLookups", false);
+
+    /**
      * {@code true} if we think we are running in a web container, based on the boolean value of system property
      * "log4j2.is.webapp", or (if this system property is not set) whether the  {@code javax.servlet.Servlet} class
      * is present in the classpath.

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd18e9b2/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java
index 8a1fb0c..cd85071 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java
@@ -17,12 +17,15 @@
 package org.apache.logging.log4j.core.pattern;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.DefaultConfiguration;
+import org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.ParameterizedMessage;
 import org.apache.logging.log4j.message.SimpleMessage;
@@ -77,6 +80,44 @@ public class MessagePatternConverterTest {
     }
 
     @Test
+    public void testLookupEnabledByDefault() {
+        assertFalse("Expected lookups to be enabled", Constants.FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS);
+    }
+
+    @Test
+    public void testLookup() {
+        final Configuration config = new DefaultConfigurationBuilder()
+                .addProperty("foo", "bar")
+                .build(true);
+        final MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null);
+        final Message msg = new ParameterizedMessage("${foo}");
+        final LogEvent event = Log4jLogEvent.newBuilder() //
+                .setLoggerName("MyLogger") //
+                .setLevel(Level.DEBUG) //
+                .setMessage(msg).build();
+        final StringBuilder sb = new StringBuilder();
+        converter.format(event, sb);
+        assertEquals("Unexpected result", "bar", sb.toString());
+    }
+
+    @Test
+    public void testDisabledLookup() {
+        final Configuration config = new DefaultConfigurationBuilder()
+                .addProperty("foo", "bar")
+                .build(true);
+        final MessagePatternConverter converter = MessagePatternConverter.newInstance(
+                config, new String[] {"nolookups"});
+        final Message msg = new ParameterizedMessage("${foo}");
+        final LogEvent event = Log4jLogEvent.newBuilder() //
+                .setLoggerName("MyLogger") //
+                .setLevel(Level.DEBUG) //
+                .setMessage(msg).build();
+        final StringBuilder sb = new StringBuilder();
+        converter.format(event, sb);
+        assertEquals("Expected the raw pattern string without lookup", "${foo}", sb.toString());
+    }
+
+    @Test
     public void testPatternWithConfiguration() throws Exception {
         final Configuration config = new DefaultConfiguration();
         final MessagePatternConverter converter = MessagePatternConverter.newInstance(config, null);


[5/5] logging-log4j2 git commit: LOG4J2-2109 Fix configuration property name

Posted by mi...@apache.org.
LOG4J2-2109 Fix configuration property name


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

Branch: refs/heads/master
Commit: 69ddd6f9f64647ae33fb63e85d57acff66e1fd45
Parents: 163eafd
Author: Mikael Ståldal <mi...@staldal.nu>
Authored: Sun Nov 12 15:33:12 2017 +0100
Committer: Mikael Ståldal <mi...@staldal.nu>
Committed: Sun Nov 12 15:33:12 2017 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/logging/log4j/core/util/Constants.java  | 2 +-
 src/site/xdoc/manual/configuration.xml.vm                        | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/69ddd6f9/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
index ef30491..fa01c13 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
@@ -61,7 +61,7 @@ public final class Constants {
      * @since 2.10
      */
     public static final boolean FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS = PropertiesUtil.getProperties().getBooleanProperty(
-            "log4j.formatMsgNoLookups", false);
+            "log4j2.formatMsgNoLookups", false);
 
     /**
      * {@code true} if we think we are running in a web container, based on the boolean value of system property

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/69ddd6f9/src/site/xdoc/manual/configuration.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
index e3042f4..3367d2c 100644
--- a/src/site/xdoc/manual/configuration.xml.vm
+++ b/src/site/xdoc/manual/configuration.xml.vm
@@ -2232,9 +2232,9 @@ public class AwesomeTest {
     when the LoggerContext is started. For debug purposes.</td>
   </tr>
   <tr>
-      <td><a name="formatMsgNoLookups"/>log4j.formatMsgNoLookups</td>
+      <td><a name="formatMsgNoLookups"/>log4j2.formatMsgNoLookups</td>
       <td>FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS</td>
-      <td><a name="log4j.formatMsgNoLookups" />log4j.formatMsgNoLookups</td>
+      <td><a name="log4j2.formatMsgNoLookups" />log4j2.formatMsgNoLookups</td>
       <td>false</td>
       <td>Disables message pattern lookups globally when set to <tt>true</tt>.
           This is equivalent to defining all message patterns using <tt>%m{nolookups}</tt>.</td>


[3/5] logging-log4j2 git commit: Closes #127

Posted by mi...@apache.org.
Closes #127


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

Branch: refs/heads/master
Commit: d3088bdca57f24565cef64413a449f88bc649c6e
Parents: 37912a7
Author: Mikael Ståldal <mi...@staldal.nu>
Authored: Sun Nov 12 15:29:08 2017 +0100
Committer: Mikael Ståldal <mi...@staldal.nu>
Committed: Sun Nov 12 15:29:08 2017 +0100

----------------------------------------------------------------------

----------------------------------------------------------------------



[4/5] logging-log4j2 git commit: LOG4J2-2109 Update changes.xml

Posted by mi...@apache.org.
LOG4J2-2109 Update changes.xml


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

Branch: refs/heads/master
Commit: 163eafd35f2e0a3422ce2ac97a7f385fa0cfb079
Parents: d3088bd
Author: Mikael Ståldal <mi...@staldal.nu>
Authored: Sun Nov 12 15:31:40 2017 +0100
Committer: Mikael Ståldal <mi...@staldal.nu>
Committed: Sun Nov 12 15:31:40 2017 +0100

----------------------------------------------------------------------
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/163eafd3/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 17ca19d..69eb04b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -31,6 +31,9 @@
          - "remove" - Removed
     -->
     <release version="2.10.0" date="2017-MM-DD" description="GA Release 2.10.0">
+      <action issue="LOG4J2-2109" dev="mikes" type="add" due-to="Carter Douglas Kozak ">
+        Add property to disable message pattern converter lookups.
+      </action>
       <action issue="LOG4J2-2112" dev="mikes" type="add" due-to="Carter Douglas Kozak ">
         MapMessage should use deep toString for values.
       </action>