Skip to content

Commit

Permalink
Merge branch '2024.2' into '2024.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
bonita-ci committed Jan 9, 2025
2 parents a706ecc + 3855ded commit f6e4dae
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions modules/setup-dev-environment/pages/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,63 @@ Here is an example of the Log4j2 configuration for the logger used in the exampl
<Logger name="org.bonitasoft.groovy.script" level="TRACE"/>
----


==== 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

To change the Bonita Studio log level (usually to debug Studio), go to the Studio installation folder, configuration directory, and edit the `config.ini` file. You need to set the property `eclipse.log.level` to one of the following values: INFO, WARNING or ERROR.
Expand Down

0 comments on commit f6e4dae

Please sign in to comment.