← Study Notes DevOps


DevOps

Logging

Recording timestamped events from your app and infrastructure so you can debug, audit and reconstruct what happened after the fact. Structured (JSON) logs with correlation IDs, shipped to a central store like ELK or Loki, stay searchable at scale. Balance signal against noise and cost — and never log secrets or personal data.


Purpose

Logs are the timestamped record of what a system actually did — requests handled, errors thrown, decisions taken — so you can debug and reconstruct events after the fact. Where metrics say how much, logs say what exactly happened.

When to Use It

Debugging production incidents ('what did this request do at 14:32?'), audit trails for security-relevant actions, and forensic reconstruction after failures. Centralised and searchable, they answer questions you did not know you would ask.

Trade-offs

Volume is money and noise: logging everything at debug level in production drowns signal and inflates storage bills. The security dimension is sharp — logs that capture passwords, tokens or personal data become a breach in waiting.

Implementation

Log structured JSON, not prose, with levels used honestly (error means action needed). Attach a correlation ID to each request and propagate it across services so one flow can be reassembled. Ship to a central store (ELK, Loki, or a hosted service), set retention policies, and scrub secrets and PII at the source.