Logging

Log levels

The following log levels are used in Rancher:

NameDescription
infoLogs informational messages. This is the default log level.
debugLogs more detailed messages that can be used to debug.
traceLogs very detailed messages on internal functions. This is very verbose and can contain sensitive information.

How to configure a log level

Kubernetes install

  • Configure debug log level
  1. $ KUBECONFIG=./kube_config_cluster.yml
  2. $ kubectl -n cattle-system get pods -l app=rancher --no-headers -o custom-columns=name:.metadata.name | while read rancherpod; do kubectl -n cattle-system exec $rancherpod -c rancher -- loglevel --set debug; done
  3. OK
  4. OK
  5. OK
  6. $ kubectl -n cattle-system logs -l app=rancher -c rancher
  • Configure info log level
  1. $ KUBECONFIG=./kube_config_cluster.yml
  2. $ kubectl -n cattle-system get pods -l app=rancher --no-headers -o custom-columns=name:.metadata.name | while read rancherpod; do kubectl -n cattle-system exec $rancherpod -c rancher -- loglevel --set info; done
  3. OK
  4. OK
  5. OK

Docker Install

  • Configure debug log level
  1. $ docker exec -ti <container_id> loglevel --set debug
  2. OK
  3. $ docker logs -f <container_id>
  • Configure info log level
  1. $ docker exec -ti <container_id> loglevel --set info
  2. OK

Rancher machine debug logs

If you need to troubleshoot the creation of objects in your infrastructure provider of choice, rancher-machine debug logs might be helpful to you.

It’s possible to enable debug logs for rancher-machine by setting environment variables when launching Rancher.

The CATTLE_WHITELIST_ENVVARS environment variable allows users to whitelist specific environment variables to be passed down to rancher-machine during provisioning.

The MACHINE_DEBUG variable enables debug logs in rancher-machine.

Thus, by setting MACHINE_DEBUG=true and adding MACHINE_DEBUG to the default list of variables in CATTLE_WHITELIST_ENVVARS (e.g. CATTLE_WHITELIST_ENVVARS=HTTP_PROXY,HTTPS_PROXY,NO_PROXY,MACHINE_DEBUG) it is possible to enable debug logs in rancher-machine when provisioning RKE1, RKE2 and k3s clusters.

Logging - 图1caution

Just like the trace log level above, rancher-machine debug logs can contain sensitive information.