intermediate

Centralized logging

Ship structured logs with correlation IDs, service names, versions, and error context so incidents can be reconstructed.

Structured logs aggregated in a central system (ELK, Loki, CloudWatch) let operators reconstruct incidents across services. Include correlation and trace IDs, service name, version, level, and error stack — not prose paragraphs per line.

Trade-off: volume and cost versus debuggability; PII in logs creates compliance risk.

On interviews: design a log line for a failed payment; query logs by trace ID across services.

Common pitfalls: printf debugging only in prod; inconsistent field names; logging secrets or full card numbers.

Checklist:

  • Use structured JSON or key-value fields.
  • Correlate logs with trace and request IDs.
  • Define retention and access controls.
  • Alert on error rate patterns, not every log line.