Skip to content

Commit

Permalink
Merge branch '2024.3' into '2025.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
vhemery committed Jan 9, 2025
2 parents 863daac + f6e4dae commit 2e92466
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion modules/setup-dev-environment/pages/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,64 @@ req.correlationId.attributeName track.correlationId
req.correlationId.headerName X-Correlation-ID
----

This properties could be update in the console-config.properties file. You need to use the setup tool provided in `workspace/tomcat/setup/` to update `console-config.properties`.
These properties can be updated in the console-config.properties file. You need to use the setup tool provided in `workspace/tomcat/setup/` to update `console-config.properties`.


==== Use JSON format for logs

The default configuration contains an unused `Console-JSON` appender which formats logs as JSON.

[source, xml]
----
<Appenders>
<!-- use json logger if json output is required -->
<Console name="Console-JSON" target="SYSTEM_OUT">
<JSONLayout compact="true" eventEol="true" properties="true" stacktraceAsString="true">
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd'T'HH:mm:ss.SSSZ}"/>
</JSONLayout>
</Console>
<!-- [...] -->
</Appenders>
----

To use it, you can update the `AppenderRef` in the `Loggers` block or add a new one.

[source, xml]
----
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console-JSON"/>
</Root>
</Loggers>
----

==== Stream logs to a remote server

You need to declare a Socket appender in `log4j-appenders.xml` to stream to a remote server. You can choose to use Socket with various formats, such as JSONLayout or PatternLayout.

As example, this configuration is used to stream JSON-formatted log entries to a remote server, such as Logstash, for further processing and analysis.

[source, xml]
----
<Socket name="runtimeLogSocket" host="<host>" port="<port>">
<JSONLayout compact="true" eventEol="true" properties="true" stacktraceAsString="true">
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd'T'HH:mm:ss.SSSZ}"/>
</JSONLayout>
</Socket>
----

Then, do not forget to reference this new appender in `Loggers` block:

[source, xml]
----
<Loggers>
<Root level="INFO">
<!-- [...] -->
<AppenderRef ref="runtimeLogSocket"/> <!-- Add this AppenderRef -->
<!-- [...] -->
</Root>
</Loggers>
----


=== Bonita Studio
Expand Down

0 comments on commit 2e92466

Please sign in to comment.