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


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 927f2ba  LOG4J2-2588 - Add option to restore printing timeMillis in 
the JsonLayout.
927f2ba is described below

commit 927f2ba66e9851e5527de106497969392b7fb483
Author: Ralph Goers <[email protected]>
AuthorDate: Sun Apr 19 14:22:17 2020 -0700

    LOG4J2-2588 - Add option to restore printing timeMillis in the JsonLayout.
---
 .../logging/log4j/core/jackson/JsonConstants.java  |  1 +
 .../log4j/core/jackson/LogEventJsonMixIn.java      |  5 +-
 .../core/jackson/LogEventWithContextListMixIn.java |  5 +-
 .../logging/log4j/core/jackson/XmlConstants.java   |  1 +
 .../log4j/core/layout/AbstractJacksonLayout.java   | 17 +++++
 .../logging/log4j/core/layout/JacksonFactory.java  | 47 +++++++++++++-
 .../logging/log4j/core/layout/JsonLayout.java      | 10 +--
 .../logging/log4j/core/layout/XmlLayout.java       | 14 ++--
 .../logging/log4j/core/layout/YamlLayout.java      | 11 ++--
 .../log4j/core/layout/JsonLayoutMillisTest.java    | 74 ++++++++++++++++++++++
 .../resources/log4j2-json-layout-timestamp.xml     | 31 +++++++++
 src/changes/changes.xml                            |  3 +
 src/site/xdoc/manual/layouts.xml.vm                |  6 ++
 13 files changed, 202 insertions(+), 23 deletions(-)

diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/JsonConstants.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/JsonConstants.java
index bb9898d..c559207 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/JsonConstants.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/JsonConstants.java
@@ -32,4 +32,5 @@ public final class JsonConstants {
     public static final String ELT_EXTENDED_STACK_TRACE = "extendedStackTrace";
     public static final String ELT_NANO_TIME = "nanoTime";
     public static final String ELT_INSTANT = "instant";
+    public static final String ELT_TIME_MILLIS = "timeMillis";
 }
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java
index 1053ad3..f95b6ef 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java
@@ -127,9 +127,8 @@ abstract class LogEventJsonMixIn implements LogEvent {
     @Override
     public abstract ThrowableProxy getThrownProxy();
 
-    @JsonIgnore // ignore from 2.11
-//    @JsonProperty()
-//    @JacksonXmlProperty(isAttribute = true)
+    @JsonProperty(JsonConstants.ELT_TIME_MILLIS)
+    @JacksonXmlProperty(isAttribute = true)
     @Override
     public abstract long getTimeMillis();
 
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventWithContextListMixIn.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventWithContextListMixIn.java
index 12b61fa..b4f7b76 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventWithContextListMixIn.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventWithContextListMixIn.java
@@ -126,9 +126,8 @@ abstract class LogEventWithContextListMixIn implements 
LogEvent {
     @Override
     public abstract ThrowableProxy getThrownProxy();
 
-    @JsonIgnore // ignore from 2.11
-//    @JsonProperty()
-//    @JacksonXmlProperty(isAttribute = true)
+    @JsonProperty(JsonConstants.ELT_TIME_MILLIS)
+    @JacksonXmlProperty(isAttribute = true)
     @Override
     public abstract long getTimeMillis();
 
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/XmlConstants.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/XmlConstants.java
index 0871440..4fd48e6 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/XmlConstants.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/XmlConstants.java
@@ -27,6 +27,7 @@ public final class XmlConstants {
     public static final String ELT_EVENT = "Event";
     public static final String ELT_EXTENDED_STACK_TRACE = "ExtendedStackTrace";
     public static final String ELT_EXTENDED_STACK_TRACE_ITEM = 
"ExtendedStackTraceItem";
+    public static final String ELT_TIME_MILLIS = "TimeMillis";
     public static final String ELT_INSTANT = "Instant";
     public static final String ELT_MARKER = "Marker";
     public static final String ELT_MESSAGE = "Message";
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 50a25c4..1cdce04 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
@@ -83,6 +83,9 @@ abstract class AbstractJacksonLayout extends 
AbstractStringLayout {
         @PluginBuilderAttribute
         private boolean includeNullDelimiter = false;
 
+        @PluginBuilderAttribute
+        private boolean includeTimeMillis = false;
+
         @PluginElement("AdditionalField")
         private KeyValuePair[] additionalFields;
 
@@ -128,6 +131,10 @@ abstract class AbstractJacksonLayout extends 
AbstractStringLayout {
 
         public boolean isIncludeNullDelimiter() { return includeNullDelimiter; 
}
 
+        public boolean isIncludeTimeMillis() {
+            return includeTimeMillis;
+        }
+
         public KeyValuePair[] getAdditionalFields() {
             return additionalFields;
         }
@@ -193,6 +200,16 @@ abstract class AbstractJacksonLayout extends 
AbstractStringLayout {
         }
 
         /**
+         * Whether to include the timestamp (in addition to the Instant) 
(optional, default to false).
+         *
+         * @return this builder
+         */
+        public B setIncludeTimeMillis(final boolean includeTimeMillis) {
+            this.includeTimeMillis = includeTimeMillis;
+            return asBuilder();
+        }
+
+        /**
          * Additional fields to set on each log event.
          *
          * @return this builder
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
index b4c914c..5ec1a4f 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
@@ -21,6 +21,7 @@ import java.util.Set;
 
 import javax.xml.stream.XMLStreamException;
 
+import com.fasterxml.jackson.databind.ser.FilterProvider;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.jackson.JsonConstants;
 import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
@@ -60,6 +61,16 @@ abstract class JacksonFactory {
         }
 
         @Override
+        protected String getPropertyNameForTimeMillis() {
+            return JsonConstants.ELT_TIME_MILLIS;
+        }
+
+        @Override
+        protected String getPropertyNameForInstant() {
+            return JsonConstants.ELT_INSTANT;
+        }
+
+        @Override
         protected String getPropertNameForSource() {
             return JsonConstants.ELT_SOURCE;
         }
@@ -100,6 +111,16 @@ abstract class JacksonFactory {
         }
 
         @Override
+        protected String getPropertyNameForTimeMillis() {
+            return XmlConstants.ELT_TIME_MILLIS;
+        }
+
+        @Override
+        protected String getPropertyNameForInstant() {
+            return XmlConstants.ELT_INSTANT;
+        }
+
+        @Override
         protected String getPropertNameForContextMap() {
             return XmlConstants.ELT_CONTEXT_MAP;
         }
@@ -143,6 +164,16 @@ abstract class JacksonFactory {
         }
 
         @Override
+        protected String getPropertyNameForTimeMillis() {
+            return JsonConstants.ELT_TIME_MILLIS;
+        }
+
+        @Override
+        protected String getPropertyNameForInstant() {
+            return JsonConstants.ELT_INSTANT;
+        }
+
+        @Override
         protected String getPropertNameForContextMap() {
             return JsonConstants.ELT_CONTEXT_MAP;
         }
@@ -207,6 +238,10 @@ abstract class JacksonFactory {
 
     }
 
+    abstract protected String getPropertyNameForTimeMillis();
+
+    abstract protected String getPropertyNameForInstant();
+
     abstract protected String getPropertNameForContextMap();
 
     abstract protected String getPropertNameForSource();
@@ -220,14 +255,24 @@ abstract class JacksonFactory {
     abstract protected PrettyPrinter newPrettyPrinter();
 
     ObjectWriter newWriter(final boolean locationInfo, final boolean 
properties, final boolean compact) {
+        return newWriter(locationInfo, properties, compact, false);
+    }
+
+    ObjectWriter newWriter(final boolean locationInfo, final boolean 
properties, final boolean compact,
+            final boolean includeMillis) {
         final SimpleFilterProvider filters = new SimpleFilterProvider();
-        final Set<String> except = new HashSet<>(2);
+        final Set<String> except = new HashSet<>(3);
         if (!locationInfo) {
             except.add(this.getPropertNameForSource());
         }
         if (!properties) {
             except.add(this.getPropertNameForContextMap());
         }
+        if (includeMillis) {
+            except.add(getPropertyNameForInstant());
+        } else {
+            except.add(getPropertyNameForTimeMillis());
+        }
         except.add(this.getPropertNameForNanoTime());
         filters.addFilter(Log4jLogEvent.class.getName(), 
SimpleBeanPropertyFilter.serializeAllExcept(except));
         final ObjectWriter writer = this.newObjectMapper().writer(compact ? 
this.newCompactPrinter() : this.newPrettyPrinter());
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JsonLayout.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JsonLayout.java
index 679f55c..2270e63 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JsonLayout.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JsonLayout.java
@@ -98,7 +98,7 @@ public final class JsonLayout extends AbstractJacksonLayout {
             final String footerPattern = toStringOrNull(getFooter());
             return new JsonLayout(getConfiguration(), isLocationInfo(), 
isProperties(), encodeThreadContextAsList,
                     isComplete(), isCompact(), getEventEol(), getEndOfLine(), 
headerPattern, footerPattern, getCharset(),
-                    isIncludeStacktrace(), isStacktraceAsString(), 
isIncludeNullDelimiter(),
+                    isIncludeStacktrace(), isStacktraceAsString(), 
isIncludeNullDelimiter(), isIncludeTimeMillis(),
                     getAdditionalFields(), getObjectMessageAsJsonObject());
         }
 
@@ -153,10 +153,10 @@ public final class JsonLayout extends 
AbstractJacksonLayout {
                        final boolean complete, final boolean compact, final 
boolean eventEol, final String endOfLine,
                        final String headerPattern, final String footerPattern, 
final Charset charset,
                        final boolean includeStacktrace, final boolean 
stacktraceAsString,
-                       final boolean includeNullDelimiter,
+                       final boolean includeNullDelimiter, final boolean 
includeTimeMillis,
                        final KeyValuePair[] additionalFields, final boolean 
objectMessageAsJsonObject) {
         super(config, new JacksonFactory.JSON(encodeThreadContextAsList, 
includeStacktrace, stacktraceAsString, objectMessageAsJsonObject).newWriter(
-                locationInfo, properties, compact),
+                locationInfo, properties, compact, includeTimeMillis),
                 charset, compact, complete, eventEol, endOfLine,
                 
PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(headerPattern).setDefaultPattern(DEFAULT_HEADER).build(),
                 
PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(footerPattern).setDefaultPattern(DEFAULT_FOOTER).build(),
@@ -265,7 +265,7 @@ public final class JsonLayout extends AbstractJacksonLayout 
{
             final boolean includeStacktrace) {
         final boolean encodeThreadContextAsList = properties && 
propertiesAsList;
         return new JsonLayout(config, locationInfo, properties, 
encodeThreadContextAsList, complete, compact, eventEol,
-                null, headerPattern, footerPattern, charset, 
includeStacktrace, false, false, null, false);
+                null, headerPattern, footerPattern, charset, 
includeStacktrace, false, false, false, null, false);
     }
 
     @PluginBuilderFactory
@@ -280,7 +280,7 @@ public final class JsonLayout extends AbstractJacksonLayout 
{
      */
     public static JsonLayout createDefaultLayout() {
         return new JsonLayout(new DefaultConfiguration(), false, false, false, 
false, false, false, null,
-                DEFAULT_HEADER, DEFAULT_FOOTER, StandardCharsets.UTF_8, true, 
false, false, null, false);
+                DEFAULT_HEADER, DEFAULT_FOOTER, StandardCharsets.UTF_8, true, 
false, false, false, null, false);
     }
 
     @Override
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/XmlLayout.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/XmlLayout.java
index 94f6c40..b8ef77e 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/XmlLayout.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/XmlLayout.java
@@ -76,7 +76,7 @@ public final class XmlLayout extends AbstractJacksonLayout {
         public XmlLayout build() {
             return new XmlLayout(getConfiguration(), isLocationInfo(), 
isProperties(), isComplete(),
                     isCompact(), getEndOfLine(), getCharset(), 
isIncludeStacktrace(), isStacktraceAsString(),
-                    isIncludeNullDelimiter(), getAdditionalFields());
+                    isIncludeNullDelimiter(), isIncludeTimeMillis(), 
getAdditionalFields());
         }
     }
 
@@ -86,16 +86,17 @@ public final class XmlLayout extends AbstractJacksonLayout {
     @Deprecated
     protected XmlLayout(final boolean locationInfo, final boolean properties, 
final boolean complete,
                         final boolean compact, final Charset charset, final 
boolean includeStacktrace) {
-        this(null, locationInfo, properties, complete, compact, null, charset, 
includeStacktrace, false, false, null);
+        this(null, locationInfo, properties, complete, compact, null, charset, 
includeStacktrace,
+                false, false, false, null);
     }
 
     private XmlLayout(final Configuration config, final boolean locationInfo, 
final boolean properties,
                       final boolean complete, final boolean compact, final 
String endOfLine, final Charset charset,
                       final boolean includeStacktrace, final boolean 
stacktraceAsString,
-                      final boolean includeNullDelimiter,
+                      final boolean includeNullDelimiter, final boolean 
includeTimeMillis,
                       final KeyValuePair[] additionalFields) {
         super(config, new JacksonFactory.XML(includeStacktrace, 
stacktraceAsString).newWriter(
-            locationInfo, properties, compact),
+            locationInfo, properties, compact, includeTimeMillis),
             charset, compact, complete, false, endOfLine, null, null, 
includeNullDelimiter,
             additionalFields);
     }
@@ -189,7 +190,7 @@ public final class XmlLayout extends AbstractJacksonLayout {
             final Charset charset,
             final boolean includeStacktrace) {
         return new XmlLayout(null, locationInfo, properties, complete, 
compact, null, charset, includeStacktrace, false,
-                false, null);
+                false, false, null);
     }
 
     @PluginBuilderFactory
@@ -203,6 +204,7 @@ public final class XmlLayout extends AbstractJacksonLayout {
      * @return an XML Layout.
      */
     public static XmlLayout createDefaultLayout() {
-        return new XmlLayout(null, false, false, false, false, null, 
StandardCharsets.UTF_8, true, false, false, null);
+        return new XmlLayout(null, false, false, false, false, null, 
StandardCharsets.UTF_8, true, false, false,
+                false, null);
     }
 }
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/YamlLayout.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/YamlLayout.java
index 4cf803c..42b216f 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/YamlLayout.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/YamlLayout.java
@@ -69,7 +69,7 @@ public final class YamlLayout extends AbstractJacksonLayout {
             return new YamlLayout(getConfiguration(), isLocationInfo(), 
isProperties(), isComplete(),
                     isCompact(), getEventEol(), getEndOfLine(), headerPattern, 
footerPattern, getCharset(),
                     isIncludeStacktrace(), isStacktraceAsString(), 
isIncludeNullDelimiter(),
-                    getAdditionalFields());
+                    isIncludeTimeMillis(), getAdditionalFields());
         }
     }
 
@@ -91,9 +91,10 @@ public final class YamlLayout extends AbstractJacksonLayout {
                        final boolean complete, final boolean compact, final 
boolean eventEol, final String endOfLine,
                        final String headerPattern, final String footerPattern, 
final Charset charset,
                        final boolean includeStacktrace, final boolean 
stacktraceAsString,
-                       final boolean includeNullDelimiter,
+                       final boolean includeNullDelimiter, final boolean 
includeTimeMillis,
                        final KeyValuePair[] additionalFields) {
-        super(config, new JacksonFactory.YAML(includeStacktrace, 
stacktraceAsString).newWriter(locationInfo, properties, compact),
+        super(config, new JacksonFactory.YAML(includeStacktrace, 
stacktraceAsString)
+                        .newWriter(locationInfo, properties, compact, 
includeTimeMillis),
                 charset, compact, complete, eventEol, endOfLine,
                 
PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(headerPattern).setDefaultPattern(DEFAULT_HEADER).build(),
                 
PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(footerPattern).setDefaultPattern(DEFAULT_FOOTER).build(),
@@ -186,7 +187,7 @@ public final class YamlLayout extends AbstractJacksonLayout 
{
             final Charset charset,
             final boolean includeStacktrace) {
         return new YamlLayout(config, locationInfo, properties, false, false, 
true, null, headerPattern, footerPattern,
-                charset, includeStacktrace, false, false, null);
+                charset, includeStacktrace, false, false, false, null);
     }
 
     @PluginBuilderFactory
@@ -201,6 +202,6 @@ public final class YamlLayout extends AbstractJacksonLayout 
{
      */
     public static AbstractJacksonLayout createDefaultLayout() {
         return new YamlLayout(new DefaultConfiguration(), false, false, false, 
false, false, null, DEFAULT_HEADER,
-                DEFAULT_FOOTER, StandardCharsets.UTF_8, true, false, false, 
null);
+                DEFAULT_FOOTER, StandardCharsets.UTF_8, true, false, false, 
false, null);
     }
 }
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutMillisTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutMillisTest.java
new file mode 100644
index 0000000..5915ad2
--- /dev/null
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutMillisTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.layout;
+
+import org.apache.logging.log4j.categories.Layouts;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests the JsonLayout class with millis.
+ */
+@Category(Layouts.Json.class)
+public class JsonLayoutMillisTest {
+
+    private static final String CONFIG = "log4j2-json-layout-timestamp.xml";
+
+    private ListAppender app;
+
+    @Rule
+    public LoggerContextRule context = new LoggerContextRule(CONFIG);
+
+    private Logger logger;
+
+    private void assertEventCount(final List<LogEvent> events, final int 
expected) {
+        assertEquals("Incorrect number of events.", expected, events.size());
+    }
+
+    @Before
+    public void before() {
+        logger = context.getLogger("LayoutTest");
+        //
+        app = context.getListAppender("List").clear();
+    }
+
+    @Test
+    public void testTimestamp() {
+        logger.info("This is a test message");
+        List<String> message = app.getMessages();
+        assertTrue("No messages", message != null && message.size() > 0);
+        String json = message.get(0);
+        System.out.println(json);
+        assertNotNull("No JSON message", json);
+        assertTrue("No timestamp", json.contains("\"timeMillis\":"));
+        assertFalse("Instant is present", json.contains("instant:"));
+    }
+
+}
diff --git a/log4j-core/src/test/resources/log4j2-json-layout-timestamp.xml 
b/log4j-core/src/test/resources/log4j2-json-layout-timestamp.xml
new file mode 100644
index 0000000..7e199d1
--- /dev/null
+++ b/log4j-core/src/test/resources/log4j2-json-layout-timestamp.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<Configuration status="INFO" packages="">
+       <Appenders>
+               <List name="List">
+                       <JsonLayout compact="true" eventEol="true" 
includeTimeMillis="true"/>
+               </List>
+       </Appenders>
+
+       <Loggers>
+               <Root level="INFO">
+                       <AppenderRef ref="List"/>
+               </Root>
+       </Loggers>
+</Configuration>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0912c24..10a6a6e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.13.2" date="2020-MM-DD" description="GA Release 
2.13.2">
+      <action issue="LOG4J2-2588" dev="rgoers" type="fix">
+        Add option to restore printing timeMillis in the JsonLayout.
+      </action>
       <action issue="LOG4J2-2766" dev="rgoers" type="fix">
         Initialize pattern processor before triggering policy during 
reconriguration.
       </action>
diff --git a/src/site/xdoc/manual/layouts.xml.vm 
b/src/site/xdoc/manual/layouts.xml.vm
index fcf7bc0..c192fd2 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -491,6 +491,12 @@ logger.debug("one={}, two={}, three={}", 1, 2, 3);
               <td>If true, include full stacktrace of any logged 
#javadoc('java/lang', 'Throwable') (optional, default to true).</td>
             </tr>
             <tr>
+              <td>includeTimeMillis</td>
+              <td>boolean</td>
+              <td>If true, the timeMillis attribute is included in the Json 
payload instead of the instant. timeMillis
+                will contain the number of milliseconds since midnight, 
January 1, 1970 UTC.</td>
+            </tr>
+            <tr>
               <td>stacktraceAsString</td>
               <td>boolean</td>
               <td>Whether to format the stacktrace as a string, and not a 
nested object (optional, defaults to false).</td>

Reply via email to