kubectl logs

Pod

Syntax

kubectl logs <pod-name> [-c container] [flags]

Parameters

ParametersDescriptionExamplesLevel
-f --follow kubectl logs -f web-pod Common
-c --container Pod kubectl logs web-pod -c sidecar Common
--tail N kubectl logs web-pod --tail=100 Common
--since kubectl logs web-pod --since=1h Common
--previous kubectl logs web-pod --previous Advanced
-l --selector Pod kubectl logs -l app=web --all-containers Advanced

Examples

Pod

kubectl logs web-app-6f7b8c9d-k2m4n
and

kubectl logs -f web-app-6f7b8c9d-k2m4n --tail=50
50

kubectl logs web-pod --previous

kubectl logs web-pod --since=1h

Pod

kubectl logs -l app=web --all-containers --max-log-requests=10
Pod

Common Errors

container not foundPod -c
previous terminated container not found, previous

Tips

Related Commands