How do you choose log levels, why log to stdout in containers, and what does structured logging buy you?
Short answer
ERROR is a failure that needs a human, WARN is an anomaly already handled, INFO is an important business event, DEBUG is for diagnosis and off in production. In a container, log to stdout as JSON with fixed fields.
3 points to say:
- ERROR only when a human must act; client errors (4xx) are not ERRORs; log an exception once, where it is handled.
- Containers log to stdout/stderr: the container filesystem is temporary and the runtime already collects stdout for the agent.
- Structured logging: each line is JSON with fixed fields plus traceId; use placeholders, exception as the last argument.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.