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 2020/02/17 02:29:26 UTC

[logging-log4j2] branch release-2.x updated (360f922 -> 19f5824)

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a change to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 360f922  LOG4J2-2649 - GraalVM does not allow the use of MethodHandles
     new e44b3ac  LOG4J2-2652 - JSON output wrong when using additonal fields
     new 19f5824  LOG4J2-2652 - JSON output wrong when using additonal fields

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../logging/log4j/core/layout/AbstractJacksonLayout.java       | 10 +++++++++-
 src/changes/changes.xml                                        |  4 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)


[logging-log4j2] 02/02: LOG4J2-2652 - JSON output wrong when using additonal fields

Posted by rg...@apache.org.
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

commit 19f5824ebabbe6c0b2e5eef4ecaca8d4a2828a00
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun Feb 16 19:29:08 2020 -0700

    LOG4J2-2652 - JSON output wrong when using additonal fields
---
 src/changes/changes.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3971ce6..664b41c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,7 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.13.1" date="2019-MM-DD" description="GA Release 2.13.1">
-    <release version="2.13.1" date="2019-MM-DD" description="GA Release 2.13.1">
+      <action issue="LOG4J2-2652" dev="rgoers" type="fix">
+        JSON output wrong when using additonal fields.
+      </action>
       <action issue="LOG4J2-2649" dev="rgoers" type="fix">
         GraalVM does not allow use of MethodHandles.
       </action>


[logging-log4j2] 01/02: LOG4J2-2652 - JSON output wrong when using additonal fields

Posted by rg...@apache.org.
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

commit e44b3ac2b427909315002e9a6ca7ca37114d93ce
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun Feb 16 19:27:52 2020 -0700

    LOG4J2-2652 - JSON output wrong when using additonal fields
---
 .../logging/log4j/core/layout/AbstractJacksonLayout.java       | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractJacksonLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractJacksonLayout.java
index bae404c..50a25c4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractJacksonLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractJacksonLayout.java
@@ -29,6 +29,7 @@ import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.impl.ThrowableProxy;
 import org.apache.logging.log4j.core.jackson.XmlConstants;
 import org.apache.logging.log4j.core.lookup.StrSubstitutor;
@@ -280,6 +281,13 @@ abstract class AbstractJacksonLayout extends AbstractStringLayout {
         }
     }
 
+    private static LogEvent convertMutableToLog4jEvent(final LogEvent event) {
+        // TODO Jackson-based layouts have certain filters set up for Log4jLogEvent.
+        // TODO Need to set up the same filters for MutableLogEvent but don't know how...
+        // This is a workaround.
+        return event instanceof Log4jLogEvent ? event : Log4jLogEvent.createMemento(event);
+    }
+
     protected Object wrapLogEvent(final LogEvent event) {
         if (additionalFields.length > 0) {
             // Construct map for serialization - note that we are intentionally using original LogEvent
@@ -316,7 +324,7 @@ abstract class AbstractJacksonLayout extends AbstractStringLayout {
 
     public void toSerializable(final LogEvent event, final Writer writer)
             throws JsonGenerationException, JsonMappingException, IOException {
-        objectWriter.writeValue(writer, wrapLogEvent(event));
+        objectWriter.writeValue(writer, wrapLogEvent(convertMutableToLog4jEvent(event)));
         writer.write(eol);
         if (includeNullDelimiter) {
             writer.write('\0');