Enable debug logging

Deployment Platform
Related Documentation
Related Resources
TL;DR

Configure the zap-log-level and zap-devel environment variables via Helm values.

Enable debug logging

When installing or upgrading Kong Operator with Helm, you can enable debug logging by adding the following to your values.yaml:

cat <<EOF > values.yaml
env:
  zap_log_level: debug
  zap_devel: "true"
  zap_time_encoding: iso8601
EOF

For more details about these options, see Kong Operator configuration options.

Install Kong Operator

Run the following command to install Kong Operator using the values.yaml file we created:

helm upgrade --install kong-operator kong/kong-operator -n kong-system \
  --create-namespace \
  --set image.tag=2.4 \
  --set env.ENABLE_CONTROLLER_KONNECT=true \
  -f values.yaml
helm upgrade --install kong-operator kong/kong-operator -n kong-system \
  --create-namespace \
  --set image.tag=2.4 \
  -f values.yaml

Validate

Wait for the rollout to complete:

kubectl -n kong-system rollout status deployment/kong-operator-kong-operator-controller-manager --timeout=120s

Check that the Kong Operator logs contain the DEBUG level:

kubectl logs -n kong-system deployment/kong-operator-kong-operator-controller-manager | grep -m 1 DEBUG

You should see logs with the DEBUG level.

Development mode (--zap-devel=true) uses a console encoder with colored, human-readable output. Production mode uses JSON encoding suitable for log aggregation systems.

Cleanup

Delete the resources created in this guide. Deleting the kong-system namespace removes the operator:

rm -f values.yaml
kubectl delete --ignore-not-found namespace kong
helm uninstall kong-operator -n kong-system
kubectl delete --ignore-not-found namespace kong-system

FAQs

To return to normal logging levels, remove the debug configuration and upgrade:

helm upgrade kong-operator kong/kong-operator \
  -n kong-system \
  --reset-values

Yes, you can configure logging using flags in your values.yaml:

args:
  - --zap-log-level=debug
  - --zap-devel=true
  - --zap-time-encoding=iso8601

The env and args sections are mutually exclusive. When both are provided, args takes precedence.

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!