Dynamic Log Level Updates

You can change the log level of Kong Gateway dynamically, without restarting Kong Gateway, using the Admin API. This set of endpoints can be protected using RBAC and changes in log level are reflected in the audit log.

The log level change is propagated to all NGINX worker nodes, including the newly spawned workers.

Note: Changing the log level to debug in a production environment can rapidly fill up the disk. After debug logging, switch back to a higher level like notice or use a timeout parameter in the request query string. The default timeout for dynamically set log levels is 60 seconds.

View current log level

To view the log level of an individual node, issue a GET request passing the desired node as a path parameter:

  1. curl --request GET \
  2. --url http://localhost:8001/debug/node/log-level/

If you have the appropriate permissions, this request returns information about your current log level:

  1. {
  2. "message": "log level: notice"
  3. }

It is not possible to change the log level of the data plane or DB-less nodes.

Modify the log level for an individual Kong Gateway node

To change the log level of an individual node, issue a PUT request passing the desired node and log-level as path parameters:

  1. curl --request PUT \
  2. --url http://localhost:8001/debug/node/log-level/notice

If you have the appropriate permissions and the request is successful, you will receive a 200 response code and the following response body:

  1. {
  2. "message": "log level changed"
  3. }

Change the log level of the Kong Gateway cluster

To change the log level of every node in your cluster, issue a PUT request with the desired log-level specified as a path parameter:

  1. curl --request PUT \
  2. --url http://localhost:8001/debug/cluster/log-level/notice

If you have the appropriate permissions and the request is successful, you will receive a 200 response code and the following response body:

  1. {
  2. "message": "log level changed"
  3. }

Manage new nodes in the cluster

To ensure that the log level of new nodes that are added to the cluster remain in sync the other nodes in the cluster, change the log_level entry in kong.conf to KONG_LOG_LEVEL. This setting allows new nodes to join the cluster with the same log level as all the existing nodes.

Change the log level of all control plane Kong Gateway nodes

To change the log level of the control plane nodes in your cluster, issue a PUT request with the desired log-level specified as a path parameter:

  1. curl --request PUT \
  2. --url http://localhost:8001/debug/cluster/control-planes-nodes/log-level/notice

If you have the appropriate permissions and the request is successful, you will receive a 200 response code and the following response body:

  1. {
  2. "message": "log level changed"
  3. }