Logging to JSON format for Kubernetes

TL;DR

How do I configure the Kong Ingress Controller to log in JSON format?

Set the Ingress Controller’s --log-format flag to json (the default is text). With the Helm chart, pass it via --set ingressController.args[0]='--log-format=json', or add it under ingressController.args in your values.yaml.

Problem

By default Kong on containerized environments logs in plain text to STDOUT/STDERR. I would like this to log in a JSON format, how is this possible?

Solution

The current Kong Kubernetes Ingress Controller (KIC) has the --log-format option.

This defaults to text and can be configured to JSON. With the helm chart specifically, this can be added to the arguments for the ingress controller.

Essentially something like --set ingressController.args[0]='--log-format=json' for the helm chart deployment, or adding it to the ingressController.args of their values.yaml file for their installation if they do it that way.

Example:

helm install ingress-controller kong/kong --create-namespace --namespace kong-system --set ingressController.args[0]='--log-format=json'

Default logging format:

time="2025-02-22T17:21:15Z" level=info msg="syncing configuration" component=controller
time="2025-02-22T17:21:15Z" level=info msg="no configuration change, skipping sync to kong" component=controller

New logging format:

{"component":"controller","level":"info","msg":"syncing configuration","time":"2025-02-22T17:21:15Z"}
{"component":"controller","level":"info","msg":"no configuration change, skipping sync to kong","time":"2025-02-22T17:21:15Z"}

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!