Log integrity and retention
Protect useful evidence
Logs support investigations only when their provenance, accessibility and integrity are trustworthy. Collect only necessary security fields. For example, record login outcome and a pseudonymous actor reference, not the password, session token or complete request body. Pseudonyms may still be personal data and need protection.
Structured logging
Emit typed fields through a logging library or JSON encoder rather than concatenating untrusted text into line-oriented messages. Use allowlisted keys and bounded values, omit secrets at the producer, and check serialization and downstream rendering separately. Restrict access to originals; analyst views should expose only necessary fields. A sanitized copy is not a replacement for protected source evidence.
Integrity and access
Use protected transport, separate write/read privileges, audited administration, and append-only or immutable storage where justified. A SHA-256 digest can detect a change relative to a trusted prior digest; storing the digest beside editable evidence under the same privilege does not establish authenticity. Protect integrity metadata independently and preserve chain of custody when evidence is exported.
Retention example
A fictional team chooses 30 days for operational logs, measured from ingestion in UTC. An approved legal hold blocks normal expiry deletion until released; record hold owner, reason and review date. At day 30 the ordinary record is eligible for authorized deletion, not proof it has been deleted. Actual durations need legal, privacy, threat and cost review; backups and replicas need corresponding lifecycle rules.
Practice and pitfalls
Design a minimal event output from the lab input: include event type, source, UTC timestamp, record ID and outcome; discard non-allowlisted fields. Test digest comparison on inert text and evaluate retention cases with and without a hold. Explain why this local checksum test is not a tamper-proof logging service.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Log integrity and retention — knowledge check
Apply telemetry mapping, integrity and ingestion principles to fictional scenarios.
Which field should be excluded from a login log?
What does a digest comparison establish?
What happens at the fictional 30-day threshold with an approved hold?
Why use structured encoding?
Who should access raw logs?