SteelReed

Search

Search posts, questions…

DevOps & CloudQuestion 24 / 35

Junior

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.

needs a humananomaly, handledbusiness eventdiagnostic detailclient sent bad data, 4xxWhat happened?ERRORWARNINFODEBUG, off in prodNot an ERROR

3 points to say:

  1. ERROR only when a human must act; client errors (4xx) are not ERRORs; log an exception once, where it is handled.
  2. Containers log to stdout/stderr: the container filesystem is temporary and the runtime already collects stdout for the agent.
  3. 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.