2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Use JSON logging in Open Liberty

The JSON log format in Open Liberty makes log analysis more effective. In this video, see how to use JSON logging with Open Liberty, which will prepare you for using log analysis tools and is a good fit for Docker containers.

Sample Open Liberty configuration

This configuration, in bootstraps.properties, directs messages, trace, FFDC, access log, and audit events to stdout (console). Trace, access logs, and audit can be high volume, so you need to consider that when deciding what to include in the sources directed to the console:


If you don’t need your messages.log file, clear the source list and set message format to JSON:


Avoid having a separate trace.log file by directing trace to stdout (console). You can omit this property if you want your trace logs to be directed to your trace file:


Sample command to enable JSON logging in your Docker image using environment variables:

docker run \
 -e "WLP_LOGGING_CONSOLE_SOURCE=message,trace,accessLog,ffdc,audit" \
 -e WLP_LOGGING_JSON_FIELD_MAPPINGS=loglevel:level,message:log

Note: The WLP_LOGGING_JSON_FIELD_MAPPINGS environment variable allows you to change default JSON field names.

JQ is a (non-IBM) command-line JSON processor you can use to format the output into a more human readable format. JQ command examples:

  • Just include the message:

    alias prettylog="jq '.message' -r"

  • Include the datetime, log level, message:

    alias prettylog="jq '.ibm_datetime + \" \" + .loglevel + \"\\t\" + \" \" + .message' -r"

  • Pipe docker container logs into JQ query:

    `docker logs | prettylog

Link to logging configurations: openliberty.io/docs/ref/config/#logging.html