Home / Learn Secure SQL / Log Retention and Privacy
Log Retention and Privacy
How long to keep logs, and what should never be in them.
Theory in plain words
What it is
Log retention policy defines how long different kinds of logs are kept before being deleted or archived, balancing investigative usefulness against storage cost and privacy regulations that limit how long personal data may be retained.
Why it matters
Logs containing personal data are themselves subject to privacy regulations (covered more fully in the "Secure schema and data design" part); keeping logs forever, or logging more personal data than needed, can itself become a compliance and security liability.
Mechanically speaking
Define retention periods per log type (security/audit logs often kept longer than routine debug logs), and never log sensitive values (passwords, full card numbers, tokens) at all, redacting them before they ever reach a log line.
Shows up in
- Web application code review
- Backend development
- Database administration
Check yourself
1. A value that should never appear in a log line is...
Sensitive secrets, never logged.