diff --git a/content/en/logs/log_collection/java.md b/content/en/logs/log_collection/java.md index fb76050f75ef9..914502da97083 100644 --- a/content/en/logs/log_collection/java.md +++ b/content/en/logs/log_collection/java.md @@ -115,47 +115,42 @@ 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" >}} + + + + + + + + + + + + + +{{< /code-block >}} +{{% /collapse-content %}} + +{{% collapse-content title="Console appender" level="h4" %}} +{{< code-block lang="xml" filename="log4j2.xml" >}} + + + + + + + + + + + + + +{{< /code-block >}} +{{% /collapse-content %}} 2. Add the JSON layout dependencies to your `pom.xml`. For example: ```xml @@ -181,6 +176,7 @@ Log4j 2 includes a JSON layout. ``` +[1]: https://logging.apache.org/log4j/2.x/plugin-reference.html {{% /tab %}} {{% tab "Logback" %}}