Setting up logging for WebSphere Liberty container images

You can observe the logs that are created by WebSphere® Liberty when it is running in a container. If you emit the logs in JSON, you can then use them with a logging stack of your choice.

Configure your WebSphere Liberty container image to emit JSON formatted logs to the console (or standard-out) with your selection of WebSphere Liberty logging events by providing the following environment variables to your WebSphere Liberty Dockerfile.

//This example illustrates the use of all available logging sources.
ENV WLP_LOGGING_CONSOLE_SOURCE=message,trace,accessLog,ffdc,audit
Alternately, these environment variables can be set when you run the container. To do so, use the -e option with the run command to pass in an environment variable value.
docker run -d -p 80:9080 -p 443:9443 -e WLP_LOGGING_CONSOLE_FORMAT=JSON -e WLP_LOGGING_CONSOLE_LOGLEVEL=info -e WLP_LOGGING_CONSOLE_SOURCE=message,trace,accessLog,ffdc,audit websphere-liberty:latest

For more information, see Logging and Trace in the WebSphere Liberty documentation.