API Logging That Actually Helps: A Minimal Field Schema
Author: WebGoodPeople
Logs shouldn't be noise. They should answer one question — what happened, where, and why — in minutes, not days.
The minimal set of fields
If you log API requests, start with at least this:
request_id(correlation across every service)method+route(not just the URL as a string)status_codeduration_ms(ideally with a breakdown: upstream/db/cache)user_id/account_id/session_id(context)error_class/error_message(when there is an error)upstream_status/upstream_duration_ms(when you call external services)
Why it works
Because you can:
- assemble a single request trace by
request_id - see exactly where the time goes
- tell a "slow database" apart from "slow code"
- find a regression fast after a release
The next step
If production is a black box right now, start with logging and dashboards.
Case study: how we wired up Grafana + Loki and started seeing every API method