Logs

This section provides information related to logs.

Log and Trace Model

Recommendations:

  • Pay attention to the log level and do not leave tracing or debug parameters enabled unnecessarily.
  • Pay attention to log rotation/switching.

Log rotation

Follow the steps below to configure the maximum log file size and maximum log file number. By default, the maximum log file size is 10 MB, and the maximum number of the log file is 5.

  1. Open the docker file with the following commands.

    cd /opt/kubernetes/cfg

    vim docker

  2. Change the value of max-size and max-file in the parameter DOCKER_LOG_OPTS.

    For example:

    DOCKER_LOG_OPTS="--log-driver=json-file --log-opt labels=io.kubernetes.container.name,io.kubernetes.pod.uid --log-opt max-size=12m --log-opt max-file=6"

  3. Restart Docker to enable the changes with the following command:

    systemctl restart docke

Note The default maximum log size number and maximum log file number is recommended. Do not set a large number for the max-size and max-file. Too large maximum size and maximum file number may affect the free disk size.