Structured logging.
also: structured logs · JSON logs · log levelsWriting logs as key-value records (JSON) with consistent fields such as trace_id and user_id, so they can be searched and aggregated.
the two-minute refresher
- 'payment failed for 123' is hard to query; {event: payment_failed, user_id: 123, trace_id: …} is easy.
- Use levels deliberately: ERROR needs attention, WARN is unusual, INFO is business events, DEBUG is off in production.
- Never log secrets or personal data.