Skip to main content
Retrieve logs from a pod or container in your Kubernetes cluster.

Usage

clanker k8s logs [pod-name] [flags]

Arguments

pod-name
string
required
Name of the pod to get logs from

Flags

-c, --container
string
Container name (required for multi-container pods)
-f, --follow
boolean
Follow log output (stream logs in real-time)
-p, --previous
boolean
Get logs from the previous terminated container
--tail
integer
default:"100"
Number of lines from the end of logs to show
--since
string
Show logs since a duration (e.g., 1h, 30m, 10s)
--timestamps
boolean
Include timestamps on each line
--all-containers
boolean
Get logs from all containers in the pod
-n, --namespace
string
default:"default"
Kubernetes namespace

Examples

Get recent logs from a pod

clanker k8s logs my-pod
2024-03-01 10:15:23 Starting application...
2024-03-01 10:15:24 Server listening on port 8080
2024-03-01 10:15:25 Connected to database
2024-03-01 10:15:30 Received request: GET /api/health
2024-03-01 10:15:31 Response sent: 200 OK

Follow logs in real-time

clanker k8s logs my-pod -f

Get logs from a specific container

clanker k8s logs my-pod -c my-container

Get last 50 lines with timestamps

clanker k8s logs my-pod --tail 50 --timestamps
2024-03-01T10:15:23.123Z Starting application...
2024-03-01T10:15:24.456Z Server listening on port 8080
2024-03-01T10:15:25.789Z Connected to database

Get logs from the last hour

clanker k8s logs my-pod --since 1h

Get logs from all containers

clanker k8s logs my-pod --all-containers

Get logs from previous container instance

Useful when a container has crashed and restarted:
clanker k8s logs my-pod -p

Get logs from a pod in a different namespace

clanker k8s logs nginx -n kube-system
Use the -f flag to tail logs in real-time, similar to tail -f. Press Ctrl+C to stop following.
If a pod has multiple containers, you must specify the container name using -c or use --all-containers to see logs from all containers.

Build docs developers (and LLMs) love