Quarkus: Advanced JSON logging formatter

Created on 3 Aug 2020  路  2Comments  路  Source: quarkusio/quarkus

Description
Looks like the Quarkus is using the same JSON formatter like Wildfly for the logs. In the customer projects this was always an issue not because it did not work, but we always needed to tweak the logs in most cases (reports, operation support, correct type in Kibana, ...). If multiple vendors are working in the project in most cases there is a definition how the logs should look like.
We ended up with own wildfly module and now with Quarkus we have our own extension.

We have always the same requirements in the projects:

  • put custom business information to the MDC
  • define the root attribute in the JSON log (move MDC attribute to the root)
  • group multiple MDC keys by the prefix
  • set up correct type (for example ID type of long in Java should be long in the JSON)

Would it be possible to have this kind of the "extended" JSON formatter in the Quarkus?
We can always help with a testing and implementation.

Implementation ideas
Custom JSON formatter
The extension which have this configuration:
json.keys.mdc - comma separated list of mapping mdc_key=root_key.
json.keys.group - comma separated list of MDC group prefix and root keymdc_prefix=root_key. Group all MDC keys with a prefix.
json.keys.ignore - ignore key.
json.keys.type - comma separated list of key and type key=long. Types are int, long and double.

Example of JSON advanced formatter:
json_runtime_src_main_java_org_tkit_quarkus_log_json_JsonAdvancedFormatter.zip

kinenhancement triagout-of-date

Most helpful comment

There is an already openned issue that ask for custom format for the JSON logging: https://github.com/quarkusio/quarkus/issues/7451

It's to achieve structured logging.

All 2 comments

There is an already openned issue that ask for custom format for the JSON logging: https://github.com/quarkusio/quarkus/issues/7451

It's to achieve structured logging.

Improvements in the JSON logging is currently being done in https://github.com/quarkiverse/quarkiverse-logging-json

See https://github.com/quarkusio/quarkus/issues/7451#issuecomment-704430638 for more details

Was this page helpful?
0 / 5 - 0 ratings