---
title: "Keep logs for a fixed time · Agent Wranglers"
url: https://agentwranglers.se/playbook/operations/logs/log-retention
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep logs for a fixed time

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

- Level: Required
- Chapter: [Logs](https://agentwranglers.se/playbook/operations/logs)
- Rule: Keep logs only as long as you need them, delete them on a schedule, and say how long in the privacy policy.
- How: Set rotation and deletion in the log store, such as logrotate, journald `MaxRetentionSec` or the retention setting of a hosted service. Weeks are usually enough for debugging. Security logs may need longer, so keep them apart with their own limit. Email delivery logs follow the same idea, as in [lean email logs](https://agentwranglers.se/playbook/email/email-privacy/lean-email-logs).
- Check: The oldest file or entry in each log store is younger than its stated limit, and the privacy policy names the same limit.

Example:

```text
/var/log/shop/*.log {
  daily
  rotate 14
  compress
  missingok
}
```

**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 operations playbook: https://agentwranglers.se/playbook/operations/logs/log-retention`.

- Previous: [Keep personal data out of logs](https://agentwranglers.se/playbook/operations/logs/logs-without-personal-data)
- [Logs](https://agentwranglers.se/playbook/operations/logs)
