Updated on 2025-05-30 GMT+08:00

ccictl logs

Scenario

Print the logs of a container in a pod or a specified resource. If a pod has only one container, the container name is optional.

ccictl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]

Examples

# Return snapshot logs of the nginx pod that contains only one container.
ccictl logs nginx

# Return snapshot logs from the nginx pod, with the source pod and container name as the prefix of each line.
ccictl logs nginx --prefix

# Return snapshot logs from the nginx pod. The output is limited to 500 bytes.
ccictl logs nginx --limit-bytes=500

# Return snapshot logs from the nginx pod and wait for the pod to start for a maximum of 20 seconds.
ccictl logs nginx --pod-running-timeout=20s

# Return snapshot logs of the nginx pod that contains multiple containers.
ccictl logs nginx --all-containers=true

# Return the snapshot logs of all containers in the pods with the app=nginx label.
ccictl logs -l app=nginx --all-containers=true

# Return snapshot logs of containers in the pods with the app=nginx label. Concurrent log requests can be sent to a maximum of 10 pods.
ccictl logs -l app=nginx --max-log-requests=10

# Return the logs of the ruby container that was terminated in the web-1 pod.
ccictl logs -p -c ruby web-1

# Start streaming logs from the Nginx pod, even if an error occurs.
ccictl logs nginx -f --ignore-errors=true

# Start streaming logs of the ruby container in the web-1 pod.
ccictl logs -f -c ruby web-1

# Start streaming logs of all containers in the pods with the app=nginx label.
ccictl logs -f -l app=nginx --all-containers=true

# Display only the last 20 lines of the nginx pod output.
ccictl logs --tail=20 nginx

# Display all logs written by the nginx pod in the last hour.
ccictl logs --since=1h nginx

# Display all logs that contain timestamps in the nginx pod from 06:00:00 UTC on August 30, 2024.
ccictl logs nginx --since-time=2024-08-30T06:00:00Z --timestamps=true

# Display the logs of the nginx pod and skip the kubelet certificate verification.
ccictl logs --insecure-skip-tls-verify-backend nginx

# Return snapshot logs of the nginx-1 container of the nginx Deployment.
ccictl logs deployment/nginx -c nginx-1

Options

--all-containers

Obtain logs of all containers in a pod.

-c, --container string

Print logs of a container in a pod.

-f, --follow

Specify whether the logs should be streamed.

-h, --help

Help information for logs

--ignore-errors

If you are watching or following pod logs, any non-fatal errors are allowed.

--insecure-skip-tls-verify-backend

Skip kubelet identity authentication for the log request source. Theoretically, attackers may provide invalid log content. If the certificate provided by kubelet has expired, you may need to use this option.

--limit-bytes int

Maximum number of bytes of logs to return. No limit is specified by default.

--max-log-requests int     Default: 5

Specify the maximum number of concurrent logs that must be followed when a selector is used. The default value is 5.

--pod-running-timeout duration     Default: 20s

The length of time to wait until at least one pod is running (the value must be greater than 0, for example, 5s, 2 min, or 3h).

--prefix

Add the log source (pod name and container name) prefix to the beginning of each log line.

-p, --previous

If the value is true, print the logs of the previous instance of the container in the pod (if it exists).

-l, --selector string

Selector used for filtering (label query). The value can be =, ==, or !=, for example, -l key1=value1,key2=value2. Matched objects must meet all specified label constraints.

--since duration

Only logs that are newer than a relative duration (like 5s, 2 min, or 3h) are returned. By default, all logs are returned. Only one of since-time and since can be used.

--since-time string

Return logs generated after a specific date (RFC3339). By default, all logs are returned. Only one of since-time and since can be used.

--tail int     Default: -1

Number of lines in the latest log file to be displayed. If no selector is specified, the default value is -1, indicating that all log lines are displayed. If a selector is provided, the default value is 10.

--timestamps

Each line of the log output contains a timestamp.

The following ccictl options can also be used in subcommands:

Parent command options