In a containerized app, where should application logs go?
Options
- To a file inside the container, and nowhere else at all
- To stdout or stderr, where the platform collects them (Correct option)
- Nowhere, since logs are not needed for apps in production
- By email to the team each time that an event happens
Answer
To standard output (stdout/stderr), where the platform collects and ships them to a logging system
Why
Files inside a container disappear when it is replaced, and with many containers you could never find them.
Write logs to stdout/stderr; Docker and Kubernetes capture them, and a logging stack (CloudWatch, ELK, Loki, Datadog) collects them centrally so you can search across all instances.
Structured logs (JSON with fields like request_id) are easier to search.
Remember
Containers: log to stdout, collect centrally.