5 lessons

Logs

Discrete events with enough context to reconstruct a failure: structured fields over prose, levels that mean something, correlation ids that survive every hop, and the secrets that must never reach log storage.

SymptomSignalMeasurementHypothesisEvidenceRoot CauseChangeValidationRegression Check

Every lesson below starts from an observable symptom and ends with the measurement that proves the fix worked. Numbers carry a label saying whether they were measured, estimated, simulated or invented to show a shape.

Structured Logging: Fields a Program Can Read

A log line is either a sentence a human greps or a record a program queries. The difference decides whether "how many payment timeouts hit provider X in the last hour" takes ten seconds or an afternoon of regex archaeology.

Symptom · During an incident, answering "how many checkouts failed and why" means a chain of greps, cuts and sorts against free-form text — and the answer is only as good as the regex someone wrote under pressure.
Log Levels Are a Convention, Not a Standard

Nothing in any specification says what `warn` means. What it means is whatever your team decided, written down or not — and when it was never written down, everything becomes `info`, the error rate becomes unmeasurable, and the level field stops carrying information.

Symptom · Filtering to `level=error` produces both real outages and routine validation failures, so nobody filters on it. Meanwhile a genuine failure is sitting at `info` because the author was not sure.
Correlation IDs: Turning Lines Into a Story

Without a shared identifier, logs from five services are five unrelated piles sorted by time. With one id propagated through every hop — and stored in a dedicated field — they become one request's story, and the log line becomes a doorway into the trace.

Symptom · A customer reports a failed checkout at 14:03. There were 68,000 checkouts that minute, and no way to tell which log lines across six services belong to theirs.
What You Just Wrote Into a Log Half the Company Can Read

Log storage has a wider read audience, a longer retention and weaker access controls than the database the data came from. A token logged once is a token in a search index, in backups, and in whatever third-party service ships your logs — and no rotation policy knows it is there.

Symptom · A routine audit finds live bearer tokens in the log search index. Nobody logged them deliberately — a debug line dumped a request object, and the header came along.
The Log Bill and What It Is Buying

Log cost scales with traffic while its debugging value does not — the ten-thousandth identical success line teaches nothing. Sampling is how you keep the value and drop the volume, and the rule that makes it safe is simple: never sample what you would need during an incident.

Symptom · Log ingest costs more than the compute running the service. Traffic doubles and the bill doubles with it, while the questions the logs can answer stay exactly the same.