Skip to main content

Logging

Logs are your system's narrative: what happened, when it happened, and the state at that moment. Unlike metrics (which aggregate) and traces (which follow requests), logs capture fine-grained events in sequence, often with rich context.

Good logging discipline enables:

  • Troubleshooting: Quickly understand what went wrong in production
  • Compliance: Maintain audit trails for security and regulatory requirements
  • Performance Analysis: Identify slow operations and bottlenecks
  • Alerting: Trigger on error patterns or anomalies
  • Business Intelligence: Extract insights from application events

But logging has costs: storage, ingestion, and retention. Unstructured logs create signal-to-noise problems. This section covers logging as a practice: structuring logs for queryability, managing log levels, controlling retention, and protecting sensitive data.