---
title: "Log, track errors and alert · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/running-in-production/logs-and-alerts
updated: 2026-10-20
licence: "All rights reserved"
---

# Log, track errors and alert

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Running in production](https://agentwranglers.se/playbook/engineering/running-in-production)
- Rule: Write structured logs, collect every unhandled error in one place, and alert a person when errors or response times jump.
- How: 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](https://agentwranglers.se/playbook/adversarial-testing/data-and-secrets/private-data-out-of-logs) explains. For more depth, see [structured logs](https://agentwranglers.se/playbook/operations/logs/structured-logs) and [alerts on symptoms](https://agentwranglers.se/playbook/operations/alerts-and-on-call/alert-on-symptoms).
- 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.

Example:

```json
{"time":"2026-11-02T09:15:04Z","level":"error","request":"7f3c2a","event":"payment.failed","order":"A-1042","reason":"card_declined"}
```

**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`.

- Previous: [Keep settings outside the code](https://agentwranglers.se/playbook/engineering/running-in-production/settings-outside-the-code)
- Next: [Watch the service from outside](https://agentwranglers.se/playbook/engineering/running-in-production/monitoring-uptime)
- [Running in production](https://agentwranglers.se/playbook/engineering/running-in-production)
