From 59375de73e97d81601283a950fbfe081d824a00a Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Fri, 3 Jan 2025 09:50:48 -0500 Subject: [PATCH 1/3] Change the example to use the JSONTemplateLayout since JSONLayout is deprecated --- content/en/logs/log_collection/java.md | 77 ++++++++++++-------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/content/en/logs/log_collection/java.md b/content/en/logs/log_collection/java.md index fb76050f75ef9..f341e9c0be82b 100644 --- a/content/en/logs/log_collection/java.md +++ b/content/en/logs/log_collection/java.md @@ -115,47 +115,41 @@ For Log4j, log in JSON format by using the SLF4J module [log4j-over-slf4j][1] co Log4j 2 includes a JSON layout. -1. Configure an appender using the JSON layout in `log4j2.xml`. See the following example configurations for file and console appender. - - For a file appender: - - ```xml - - - - - - - - - - - - - - - ``` - - For a console appender: - - ```xml - - - - - - - - - - - - - - - - - ``` +1. Configure an appender using the JSON layout in `log4j2.xml`. See the following example configurations for file and console appender. For a comprehensive description of Log4j plugins, see the [Log4j Plugin reference][1]. +{{% collapse-content title="File appender" level="h4" %}} +{{< code-block lang="xml" filename="log4j2.xml" collapsible="false" >}} + + + + + + + + + + + + +{{< /code-block >}} +{{% /collapse-content %}} + +{{% collapse-content title="Console appender" level="h4" %}} +{{< code-block lang="xml" filename="log4j2.xml" collapsible="false" >}} + + + + + + + + + + + + + +{{< /code-block >}} +{{% /collapse-content %}} 2. Add the JSON layout dependencies to your `pom.xml`. For example: ```xml @@ -181,6 +175,7 @@ Log4j 2 includes a JSON layout. ``` +[1]: https://logging.apache.org/log4j/2.x/plugin-reference.html {{% /tab %}} {{% tab "Logback" %}} From fab892ccee729cd6f20b163a5b65d39d83ef5b9d Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Fri, 3 Jan 2025 13:57:44 -0500 Subject: [PATCH 2/3] Apply suggestions from code review --- content/en/logs/log_collection/java.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/logs/log_collection/java.md b/content/en/logs/log_collection/java.md index f341e9c0be82b..8d1527d187044 100644 --- a/content/en/logs/log_collection/java.md +++ b/content/en/logs/log_collection/java.md @@ -117,7 +117,7 @@ Log4j 2 includes a JSON layout. 1. Configure an appender using the JSON layout in `log4j2.xml`. See the following example configurations for file and console appender. For a comprehensive description of Log4j plugins, see the [Log4j Plugin reference][1]. {{% collapse-content title="File appender" level="h4" %}} -{{< code-block lang="xml" filename="log4j2.xml" collapsible="false" >}} +{{< code-block lang="xml" filename="log4j2.xml" >}} @@ -134,7 +134,7 @@ Log4j 2 includes a JSON layout. {{% /collapse-content %}} {{% collapse-content title="Console appender" level="h4" %}} -{{< code-block lang="xml" filename="log4j2.xml" collapsible="false" >}} +{{< code-block lang="xml" filename="log4j2.xml" >}} From 4ad3093c257db2da260a347e230936d5a956b15f Mon Sep 17 00:00:00 2001 From: Esther Kim Date: Fri, 3 Jan 2025 13:57:56 -0500 Subject: [PATCH 3/3] Apply suggestions from code review --- content/en/logs/log_collection/java.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/en/logs/log_collection/java.md b/content/en/logs/log_collection/java.md index 8d1527d187044..914502da97083 100644 --- a/content/en/logs/log_collection/java.md +++ b/content/en/logs/log_collection/java.md @@ -122,7 +122,8 @@ Log4j 2 includes a JSON layout. - + +