Dynamic Log Level Updates
You can change the log level of Kong Gateway dynamically, without restarting Kong Gateway, using the Admin API’s /debug
endpoints.
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 in a traditional cluster, including the newly spawned workers.
Notes:
- The
debug
endpoints do not work for hybrid mode data planes. They can only be used for control plane nodes.- Changing the log level to
debug
in a production environment can rapidly fill up the disk. After finishing debug logging, switch back to a higher level likenotice
or use atimeout
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:
curl --request GET \
--url http://localhost:8001/debug/node/log-level/
If you have the appropriate permissions, this request returns information about your current log level:
{
"message": "log level: notice"
}
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:
curl --request PUT \
--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:
{
"message": "log level changed"
}
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:
curl --request PUT \
--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:
{
"message": "log level changed"
}
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:
curl --request PUT \
--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:
{
"message": "log level changed"
}