Unit content
Structured application logging
A log records discrete events produced while software runs: a request failed, a job started, a configuration was loaded or an invariant was violated.
Human-readable prose is useful, but production logs become easier to search and aggregate when important fields are structured:
level=error request_id=abc123 order_id=42 error=timeout
Stable field names let tools group events without parsing sentences. Timestamps, severity and identifiers provide context, while a request or correlation identifier can connect events belonging to one operation.
Logs should record enough information to diagnose behavior without exposing secrets, credentials or unnecessary personal data.
Logging every internal step is not automatically better. Excessive volume increases cost and can hide the events that matter.
A useful log event communicates a meaningful state transition or diagnostic fact in a form that both humans and machines can interpret.