Commands.app

kubectl logs

Debugging

Print container logs

Options & Flags
Available options for this command
-f

Follow log output

-c

Container name (for multi-container pods)

--tail

Number of lines to show

--since

Only show logs since duration

-p

Show previous container logs

Examples
Common usage examples

Get pod logs

kubectl logs mypod

Follow logs in real-time

kubectl logs -f mypod

Logs from specific container

kubectl logs mypod -c mycontainer

Last 100 lines

kubectl logs mypod --tail=100

Logs from last hour

kubectl logs mypod --since=1h

Logs from pods with label

kubectl logs -l app=nginx
Notes
  • Use -p to view logs from crashed container
Related Commands
You might also find these useful