A small set of habits turns 3 a.m. debugging from archaeology into a quick read.
Log the decision, not just the event
"Request received" tells me almost nothing. "Routing request to shard 4 because tenant=acme" tells me why — and why is what I'm actually chasing at 3 a.m.
A few rules I hold to:
- Include the identifiers you'd grep for: request id, tenant, resource.
- Log at the boundary where a decision is made, with the inputs to that decision.
- Make the happy path quiet and the surprising path loud.
The goal isn't more logs. It's logs that answer the question you'll have later, written by the only person who understands the code right now: you, today.