[id='enabling_json_logging-{context}']
= Enabling and Configuring the JSON Log Handler
{brandname} provides a JSON log handler to write messages in JSON format.

.Prerequisites

* Stop {brandname} Server if it is running. +
You cannot dynamically enable log handlers.

.Procedure

. Open `{server_home}/server/conf/log4j2.xml` with any text editor.
. Uncomment the `JSON-FILE` appender and comment out the `FILE` appender:
+
[source,xml,options="nowrap",subs=attributes+]
----
<!--<AppenderRef ref="FILE"/>-->
<AppenderRef ref="JSON-FILE"/>
----
+
. Optionally configure the JSON appender and JSON layout as required.
. Save and close `log4j2.xml`.

When you start {brandname}, it writes each log message as a JSON map in the following file: +
`{server_home}/server/log/server.log.json`

[role="_additional-resources"]
.Additional resources

* link:https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender[RollingFileAppender]
* link:https://logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout[ JSONLayout]
