Prompt
How do I troubleshoot missing logs from a containerized app?
Latest observation
Here’s a practical checklist for troubleshooting missing logs from a containerized app:
1) Confirm the app is actually writing logs
- Check whether the app writes to:
- stdout/stderr (best for containers)
- a file inside the container
- a mounted volume
- If logs are only written to files in the container, they may disappear when the container restarts unless the file path is mounted.
2) Inspect container stdout/stderr directly
- For Docker:
docker logs <container>docker logs -f <container>
- For Kubernetes:
kubectl logs <pod>kubectl logs -f <pod> -c <container>- If the container restarted:
kubectl logs <pod> --previous
If logs appear here, the app is fine and the issue is likely with your log collector or pipeline.
3) Check the container runtime logging driver
If using Docker, verify the logging driver:
docker inspect <container> --format '{{.HostConfig.LogConfig.Type}}'
Common issues:
nonedriver disables logsjson-fileis typical and works withdocker logsjournaldsends logs to systemd journal instead of Docker’s file-based logs
4) Verify your log collector/agent
If you use Fluent Bit, Fluentd, Logstash, Filebeat, Vector, Promtail, etc.:
- Is the agent running?
- Is it reading the right path/stream?
- Does it have permission to access container log files?
- Check agent logs for:
- permission denied
- buffer full
- dropped records
- parsing failures
- connection/authentication errors to the destination
5) Check for log buffering in the app
Some runtimes buffer output, so logs may not show up immediately:
- Python: run unbuffered (
PYTHONUNBUFFERED=1orpython -u) - Node.js: usually flushes quickly, but some libraries buffer
- Java: logging framework config may buffer or async-log
- Go: standard output is usually immediate, but some loggers buffer
Try forcing flush or disabling buffering.
6) Make sure logs aren’t going to the wrong place
Common mistakes:
- App logs to
/var/log/app.logbut the collector only reads stdout - Sidecar/agent is configured for a different directory
- Wrong container name/pod label selector
- Wrong namespace in Kubernetes
7) Check permissions and ownership
If the app writes to files:
- Ensure the container user can write to the log path
- Ensure the log collector can read mounted log files
- Watch for read-only root filesystem issues
8) Look for rotation or truncation issues
Logs may “disappear” because of:
- aggressive log rotation
- log file rename without agent support
- max-size limits on Docker logs
- retention settings in Kubernetes/node logging
For Docker, check whether logs are being rotated by the runtime configuration.
9) Check resource limits and backpressure
Missing logs can happen when:
- the node disk is full
- the logging pipeline is blocked
- the collector drops logs due to memory/CPU limits
- network issues prevent shipping logs to a remote backend
10) Validate with a known test log
From inside the container or app startup, emit a simple test line:
echo "TEST LOG $(date)" >&1- or use the app’s logger to print a unique message
Then trace it:
- container stdout/stderr
- runtime logs
- collector/agent
- destination backend
This helps identify where logs stop.
11) In Kubernetes, check pod and node specifics
kubectl describe pod <pod>for restarts, events, OOMKills- Confirm the node’s log path and whether the container runtime is writing there
- Verify the cluster log agent DaemonSet is healthy on the node
12) Consider app crashes or short-lived containers
If the container exits quickly:
- logs may only be available briefly
- use
--previousin Kubernetes - ensure the process doesn’t fail before logging initializes
Quick isolation strategy
Ask:
- Does
docker logs/kubectl logsshow it?- Yes → problem is downstream logging pipeline
- No → problem is in the app, runtime, or container setup
- Does a simple test message appear?
- If not, check buffering, logging config, or runtime driver
- Are logs written to stdout/stderr?
- If not, adjust app logging to use stdout/stderr
If you want, I can give you a Docker-specific or Kubernetes-specific troubleshooting flowchart.