Security

How long to keep server and access logs

December 4, 2026

Keep access and server logs for a period you have written down and can justify, review it on a schedule, and delete on time. The law sets no number. The one regulator that prints a figure says six months to a year; the card industry says twelve months with three online; the German and American standards bodies require a process without naming a duration. For a small business with no card data on its servers, a year is defensible and six months is enough for most incidents.

What the law says

The GDPR's storage limitation principle: personal data must be "kept in a form which permits identification of data subjects for no longer than is necessary for the purposes for which the personal data are processed" (GDPR Article 5(1)(e)). An IP address with a timestamp is personal data, so a web server's access log is in scope. Recital 39 says how to comply: "time limits should be established by the controller for erasure or for a periodic review" (GDPR Recital 39).

The UK regulator is explicit that the number is yours to pick: "The UK GDPR does not set specific time limits for different types of data. This is up to you, and will depend on how long you need the data for your specified purposes", and "You need a policy setting standard retention periods wherever possible, to comply with documentation requirements" (ICO, Storage limitation). On reviews: "there is no firm rule about how regular these reviews must be."

The figures that exist

The French regulator is the one authority that prints a window. Its 2024 security guide: "Keep these logs for a rolling period of between six months and one year", with the exceptions "a legal obligation relating to this retention period, the need for litigation management, internal control or an identified need for post-incident analysis" (CNIL, Guide to the security of personal data, 2024). Its formal recommendation on logging gives the same window and adds the ceiling for the exceptions: "Dans les cas les plus courants, une durée maximale de trois ans pourra ainsi être justifiée", a maximum of three years in the commonest cases (CNIL, recommandation relative à la journalisation). An older CNIL developer sheet said six months flat; the window supersedes it.

If card data touches your systems, PCI DSS sets the floor: "Retain audit log history for at least 12 months, with at least the most recent three months immediately available for analysis" (PCI DSS v4.0, requirement 10.5.1, as reproduced in SAQ D). "Immediately available" is defined loosely: "(for example, online, archived, or restorable from backup)" (PCI SSC, Effective Daily Log Monitoring). The requirement was numbered 10.7 in version 3.2.1 with the same one year and three months.

The standards bodies set the shape and leave the number blank. NIST's control AU-11: "Retain audit records for [Assignment: organization-defined time period consistent with records retention policy] to provide support for after-the-fact investigations of incidents" (NIST SP 800-53 Rev. 5). Germany's BSI: "Protokollierungsdaten MÜSSEN nach einem festgelegten Prozess gelöscht werden", logging data must be deleted by a defined process, and it must be technically impossible to delete or alter it uncontrolled (BSI IT-Grundschutz, OPS.1.1.5). The German telecoms retention law, TKG § 176, with its ten weeks and four weeks, applies to telecommunications providers and says nothing about a company's web server.

Picking your number

LogWhy you keep itA defensible period
Web server access logIncident investigation, abuse, debugging6 to 12 months, rolling
Authentication and admin audit logInvestigation, accountability12 months
Application error logDebuggingWeeks; strip personal data if longer
Anything in a card-data environmentPCI DSS 10.5.112 months, 3 immediately available
Logs held for a dispute or an investigationLegal obligationUntil the matter closes, then delete

The reasoning to write next to the number: how long after an intrusion you expect to discover it, how long a customer dispute runs, and what your insurer or a contract requires. OWASP states the two-sided rule: log data "must not be destroyed before the duration of the required data retention period, and must not be kept beyond this time. Legal, regulatory and contractual obligations may impact on these periods" (OWASP Logging Cheat Sheet).

Making the deletion happen

A retention period that nobody enforces is a number in a document. Log rotation with a maximum age does the enforcement on a single server; a central log store needs its own lifecycle rule. NIST notes the mismatch that creates archives: "organizations might need to keep copies of log files for a longer period of time than the original log sources can support, which necessitates establishing log archival processes" (NIST SP 800-92). Archives need the same deletion date as the source.

Two protections go with the period. Logs are evidence, so "Because of their usefulness as a defense, logs may be a target of attacks" (OWASP); BSI's recommendation is that the administrators who run the systems should not themselves have the right to alter or delete the logs (OPS.1.1.5.A10). And clocks must agree, "Synchronize time across all servers and devices" (OWASP), or the log cannot order events across machines.

How to log a login attempt covers what goes into the authentication log in the first place, and How to respond when a company laptop is stolen is the kind of incident the retention period is sized for.

Sources