Logs
Write one structured line per event, tie it to the request that caused it, and keep personal data out. Then logs answer questions instead of hiding them.
- Required 2
- Recommended 5
Required
Keep personal data out of logs
OPS-9Never log passwords, tokens, full card numbers or personal details. Log IDs instead, and drop or shorten IP addresses.
Keep logs for a fixed time
OPS-10 EU lawKeep logs only as long as you need them, delete them on a schedule, and say how long in the privacy policy.
Recommended
Log structured events
OPS-6Write each log entry as one line of structured data, such as JSON, with a time, a level, an event name and its fields.
Tie every line to its request
OPS-7Give every request an ID, pass it to every service it touches, and write it on every log line and error page.
Use log levels with fixed meanings
OPS-8Use a small set of levels, each with one meaning, and run production at info level.
Escape line breaks in every logged value
OPS-76Write each outside value into its own log field, through an encoder that escapes carriage returns, line feeds and other control characters. Never paste input into the message text.
Send logs off the machine as they are written
OPS-11Ship every log line to a store on another machine within 60 seconds of writing it. The server's own credentials must not be able to edit or delete it there.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/logs">Agent Wranglers operations and observability playbook</a>. In code you write, add a comment next to it with the same link.