vy commented on a change in pull request #543:
URL: https://github.com/apache/logging-log4j2/pull/543#discussion_r663706396



##########
File path: src/site/asciidoc/manual/json-template-layout.adoc.vm
##########
@@ -410,6 +410,15 @@ artifact, which contains the following predefined event 
templates:
   xref:additional-event-template-fields[additional event template fields]
   to avoid `hostName` property lookup at runtime, which incurs an extra cost.)
 
+- 
https://github.com/apache/logging-log4j2/tree/master/log4j-layout-template-json/src/main/resources/GcpLayout.json[`GcpLayout.json`]
+  described by https://cloud.google.com/logging/docs/structured-logging[Google
+  Cloud Platform Structured logging] with additional
+  `_thread`, `_logger` and `_exception` fields. The exception trace, if any,
+  is written to the `_exception` field as well as the `message` field --
+  the former is useful for explicitly searching/analyzing structured exception
+  information, while the latter is Google's expected place for the exception,
+  and integrates with Google Error Reporting.

Review comment:
       ```suggestion
     and integrates with https://cloud.google.com/error-reporting[Google Error 
Reporting].
   ```

##########
File path: src/changes/changes.xml
##########
@@ -31,6 +31,9 @@
     -->
     <release version="2.15.0" date="2021-MM-DD" description="GA Release 
2.15.0">
       <!-- ADDS -->
+      <action issue="LOG4J2-3116" dev="vy" type="add" due-to="Raman Gupta">

Review comment:
       ```suggestion
         <action issue="LOG4J2-3116" dev="rgupta" type="add">
   ```

##########
File path: src/site/asciidoc/manual/json-template-layout.adoc.vm
##########
@@ -410,6 +410,15 @@ artifact, which contains the following predefined event 
templates:
   xref:additional-event-template-fields[additional event template fields]
   to avoid `hostName` property lookup at runtime, which incurs an extra cost.)
 
+- 
https://github.com/apache/logging-log4j2/tree/master/log4j-layout-template-json/src/main/resources/GcpLayout.json[`GcpLayout.json`]
+  described by https://cloud.google.com/logging/docs/structured-logging[Google
+  Cloud Platform Structured logging] with additional

Review comment:
       ```suggestion
     Cloud Platform structured logging] with additional
   ```

##########
File path: 
log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/GcpLayoutTest.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.layout.template.json;
+
+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.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.logging.log4j.layout.template.json.TestHelpers.serializeUsingLayout;
+
+class GcpLayoutTest {
+
+    private static final Configuration CONFIGURATION = new 
DefaultConfiguration();
+
+    private static final Charset CHARSET = StandardCharsets.UTF_8;
+
+    private static final String SERVICE_NAME = "test";
+
+    private static final JsonTemplateLayout JSON_TEMPLATE_LAYOUT = 
JsonTemplateLayout
+            .newBuilder()
+            .setConfiguration(CONFIGURATION)
+            .setCharset(CHARSET)
+            .setEventTemplateUri("classpath:GcpLayout.json")
+            .build();
+
+    @Test
+    void test_lite_log_events() {
+        final List<LogEvent> logEvents = 
LogEventFixture.createLiteLogEvents(1_000);
+        test(logEvents);
+    }
+
+    @Test
+    void test_full_log_events() {
+        final List<LogEvent> logEvents = 
LogEventFixture.createFullLogEvents(1_000);
+        test(logEvents);
+    }
+
+    private static void test(final Collection<LogEvent> logEvents) {
+        for (final LogEvent logEvent : logEvents) {
+            test(logEvent);
+        }
+    }
+
+    private static void test(final LogEvent logEvent) {
+        final Map<String, Object> jsonTemplateLayoutMap = 
renderUsingJsonTemplateLayout(logEvent);
+        // for now, we just validate there are no errors

Review comment:
       @rocketraman, can we do something more meaningful here, e.g., checking a 
couple of fields against the `logEvent`?

##########
File path: src/site/asciidoc/manual/json-template-layout.adoc.vm
##########
@@ -410,6 +410,15 @@ artifact, which contains the following predefined event 
templates:
   xref:additional-event-template-fields[additional event template fields]
   to avoid `hostName` property lookup at runtime, which incurs an extra cost.)
 
+- 
https://github.com/apache/logging-log4j2/tree/master/log4j-layout-template-json/src/main/resources/GcpLayout.json[`GcpLayout.json`]
+  described by https://cloud.google.com/logging/docs/structured-logging[Google
+  Cloud Platform Structured logging] with additional
+  `_thread`, `_logger` and `_exception` fields. The exception trace, if any,
+  is written to the `_exception` field as well as the `message` field --

Review comment:
       ```suggestion
     is written to the `_exception` field as well as the `message` field –
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to