Running in production Required
Log, track errors and alert
Write structured logs, collect every unhandled error in one place, and alert a person when errors or response times jump.
How to do it
Log one line per event as JSON, with a level, a time and a request reference. Send unhandled errors to an error tracker, such as Sentry. Alert on the error rate and on slow responses, not on single events. Write each threshold down, such as more than 1% of requests failing for 5 minutes. Keep personal data out of logs, as the security testing playbook explains. For more depth, see structured logs and alerts on symptoms.
Example
{"time":"2026-11-02T09:15:04Z","level":"error","request":"7f3c2a","event":"payment.failed","order":"A-1042","reason":"card_declined"}
How to check
Throw a test error in staging. It appears in the error tracker with its request reference. Send failing requests past the written threshold, and the alert fires.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/running-in-production/logs-and-alerts.