Skip to main content
⚡ OpenDevDocs
Kubernetes Commands
devopskubernetesReferenceBeginner

kubectl logs

Print or stream standard output (stdout) and standard error (stderr) logs from containers running inside a Kubernetes Pod.

Verified: 2026-10-01
Tested on:kubernetes 1.31
Platforms:
all
#kubernetes#kubectl#logs#stdout#debugging

Command

kubectl logs -f deployment/api-server --tail=100


Short Description

kubectl logs retrieves standard output (stdout) and standard error (stderr) streams from containers in a Pod or workload controller.


Syntax

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

Examples

1. Stream Live Logs from a Pod

kubectl logs -f web-app-559d7b489d-abc12

2. View Logs from the Previous Crashed Container

kubectl logs -p web-app-559d7b489d-abc12

3. Log a Specific Container in a Multi-Container Pod

kubectl logs web-app-abc12 -c envoy-proxy

4. Stream Logs from All Pods Matching a Label

kubectl logs -f -l app=backend-api --all-containers=true

Common Options

OptionShorthandDescription
--follow-fStream logs in real time as they arrive.
--previous-pPrint logs for the previously terminated container instance.
--tailLines of recent log file to display (e.g. --tail=50).
--sinceShow logs written since a duration (e.g. --since=1h or --since=15m).
--timestampsPrefix each log line with an RFC3339 timestamp.

On this page