Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Merge branch '2024.3' into '2025.1' #2954

Closed
wants to merge 9 commits into from
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
Loading