(Note · · 5 min read)

Your logs record everything and answer nothing

The test of a logging setup is not volume. It is whether you can answer a question like: this customer says their payment failed an hour ago, what happened. If answering means reading through output looking for something familiar, the logs are a diary rather than an instrument.

By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka

Write records, not sentences

A line of prose with values pasted into it can only be searched by guessing at its wording. The same event as structured fields — event name, user, order, duration, outcome — can be filtered, counted and grouped.

That changes what you can ask. Show me every failed payment for this account today is a query against fields, and an impossibility against sentences.

Carry one identifier through everything

Attach a request identifier at the edge and pass it through every log line, every background job it starts and every outbound call it makes. Without it, a single user action is scattered across services with no way to reassemble it.

Include the stable identifiers that matter to a question — account, organisation, order — on every line rather than only where they first appear. The line you need is never the one with the context on it.

Log decisions, not just arrivals

Most logs record that something started and that it finished. The useful entries are the branches: why a request was rejected, which path a condition took, what a retry decided, why a validation failed. Those are the lines that answer why rather than whether.

Refusals especially. A permission denied, a rate limit applied, a webhook with a bad signature — each is both a debugging aid and a security signal, and each is invisible if only successes are recorded.

Keep personal data out

Logs are copied to more places, kept longer and read by more people than the database. Personal data written into them has moved somewhere with weaker access control and longer retention, which undoes careful work done elsewhere.

Redact at the point of writing rather than relying on discipline. On the payroll product I build, personal data is deliberately kept out of logs, out of traces and out of commits, which is the same rule enforced in three places. Log identifiers you can resolve, not the values themselves.

Less, but at the right moments

Logging every iteration of a loop makes the next incident harder, because the line that matters is buried. Prefer one record per meaningful unit of work with the relevant numbers attached, rather than a running commentary.

Put durations on anything that calls something else. When a system is slow, the first question is which call it is waiting on, and that is unanswerable unless somebody measured it at the time.

Test it on a real question

Pick something a support request might ask and try to answer it from the logs alone, before an incident rather than during one. The gaps you find are specific and fixable, and finding them with time to spare is the entire point.

Common questions

What makes logs useful during an incident?

Structure and a shared identifier. Structured fields can be filtered, counted and grouped, while prose can only be searched by guessing at its wording, and a request identifier carried through every line and background job lets one user action be reassembled across services.

What should be logged besides starts and finishes?

Decisions. Why a request was rejected, which branch a condition took, what a retry decided, why validation failed — these answer why rather than whether. Refusals such as denied permissions, applied rate limits and bad webhook signatures are both debugging aids and security signals.

Is it safe to log personal data?

No. Logs are copied more widely, kept longer and read by more people than the database, so personal data in them sits somewhere with weaker access control. Redact at the point of writing and log identifiers you can resolve rather than values.

How much should be logged?

Less, at the right moments. One record per meaningful unit of work with the relevant numbers beats a running commentary that buries the line you need. Always attach durations to calls to other systems, since that is the first question when something is slow.

Need something like this built?