Chapter 14: Logging and Light Observability
14.1 Why logs — flight recorder for the server
Metrics tell you that lunch broke. Logs help you answer what happened in the minutes around the break.
A log is a timestamped text (or structured JSON) event your app or OS writes: "started", "failed to connect to DB", "returned 500 on /checkout".
Why it matters for an Instagram-style badge API : when a customer cannot open the menu, you replay the CCTV — request id, error line, deploy time — instead of guessing over WhatsApp.
| Only metrics | Metrics + logs |
|---|---|
| "Error rate spiked" | "Error rate spiked because DB auth failed at 12:41" |
| Red graph | Red graph + matching log lines |
| Blame ping-pong | Shared timeline |
Ravindra Bagale's Tip
Password, token, .env values — log madhe kadhi nahi. Redact. Interview madhe hi chuk = trust break. Bilkul visru naka!