An application fails, and someone enables detailed logging to find out why. The service recovers, but the setting remains: every request continues to leave headers, parameters, and fragments of content in a file that few people review. A diagnostic tool ends up accumulating information it never needed to keep.
Log data minimization means collecting the events and attributes needed for a defined purpose, reducing their detail where possible, and deleting them when they are no longer useful. It starts before the first piece of data is written and extends to every copy.
The goal is to preserve the ability to investigate while reducing exposure. That requires deciding which questions each log must answer, testing that it can still answer them, and setting limits on its use.
What a system needs to know to defend itself
A log is a record of events: a failed login, a permissions change, an administrative action, or an error. It may contain a timestamp, service, outcome, and identifiers that connect events. It does not need to reproduce the entire interaction that generated it.
To investigate repeated login attempts, for example, the time, outcome, an account reference, and some information about the source may be useful. That does not justify storing the password entered. Nor is it necessary to log a document's contents to record that someone downloaded it.
When those attributes can identify a person, directly or in combination with other information, they fall within the scope of personal data. An IP address can be personal data; appearing in a technical file does not change that.
Within its scope of application, Articles 5, 25, and 32 of the GDPR address data minimization, storage limitation, data protection by design, and security of processing. The regulation does not require a choice between protecting data and keeping logs. Outside that scope, applicable rules must be reviewed; the technical principles remain useful.
Purposes should be separated. A security log helps detect unusual access; a debugging trace helps locate a software fault. They may require different fields, permissions, and retention periods. Combining them for convenience makes each piece of data harder to justify.
Key idea: Every log field should help answer a specific question. “It might be useful someday” defines neither a purpose nor a retention period.
What to keep out of logs
The OWASP Logging Cheat Sheet recommends excluding, masking, or transforming sensitive information according to its nature. For an application, the first line of defense is to prevent secrets from reaching the logging system.
An exclusion policy should cover at least:
- Passwords, private keys, and infrastructure secrets.
- Access tokens and session values that can be used to access an account.
- Connection strings containing credentials and authentication headers.
- Financial, health, or personal data unrelated to the purpose of the event.
- Request bodies and URL parameters that may contain private information.
For example, an Authorization: Bearer <token> header should be omitted or replaced with a marker such as [REDACTED] before it is stored. To record a password reset, the event and its outcome are enough: the full URL may contain the very secret that authorizes the operation.
Errors also need attention. An exception trace can include user input, queries, or responses from other services. Reviewing only manually written log messages leaves that route for leaks open.
There are also two distinct controls often called sanitization: removing sensitive data and neutralizing input that could alter the structure of a log. Escaping newline characters helps prevent the injection of false events, but it does not conceal a password. Both controls are necessary.
How to reduce data before storage
The strongest protection starts in the application: define a schema of permitted fields and avoid dumping entire objects. A collector such as Fluent Bit, Logstash, or Vector can add filters before central storage, but the data may already have been written to a local file or queue.
Review the entire path: application, agent, transport, and repository. Regular-expression filtering provides an additional barrier; it cannot guarantee detection of every secret and does not replace an explicit schema.
Reduce precision without losing the signal
When a subnet is sufficient, an example IPv4 address such as 198.51.100.42 can be transformed into 198.51.100.0/24. For IPv6, retaining a prefix such as /64 can be considered if it serves the purpose. These are design choices to test, not universal anonymization masks.
A prefix may still be associated with a household or organization. Less detail can also make it impossible to distinguish devices during an investigation. If a full IP address is needed for a justified security purpose, document that need and limit its retention and access.
Replace identities and control correlation
A random identifier may be enough to link events without displaying a person's email address or name. If a mapping exists, it should be stored separately with more restrictive permissions. This is pseudonymization; it does not make the person unidentifiable.
Hashing an email address does not guarantee anonymity either: if the set of possible values is predictable, someone may attempt to guess the input. Using salts, keys, and rotation requires a design suited to the risk. Rotating identifiers reduces links between periods, but also limits historical investigations.
The distinction from data anonymization matters: pseudonymized data remains personal data when it can be attributed to someone using additional information. The AEPD's privacy by design guide describes strategies such as minimizing, hiding, and separating data to address these decisions.
Limit debugging in production
The DEBUG and TRACE levels often produce extensive detail. If an incident requires them, limit the service, duration, and recipients, and arrange for automatic deactivation. Secret filters must remain active.
Choosing INFO, WARN, or ERROR is not enough either: any of these levels can contain sensitive data. What matters is the content, along with preserving critical events even when verbosity is reduced.
Key idea: Pseudonymization reduces exposure; it does not eliminate obligations concerning the data. Truncating an IP address reduces precision; it does not by itself prove that no one can be identified.
How long to retain logs
There is no universal maximum retention period for all logs. Retention must be justified by purpose, risk, applicable obligations, and the need to investigate incidents.
The CNIL recommendation on logging measures offers a rolling window of six months to one year as a reference. This is a recommendation from the French authority that must be read in context, not a worldwide obligation or a minimum for every debugging trace. Internal-control cases involving extended retention require specific justification; they do not authorize keeping the entire archive longer by default.
An operational policy might be documented as follows:
| Purpose | Data to justify | Retention criterion |
|---|---|---|
| Investigate access | Time, outcome, pseudonymized account, and necessary source information | Period needed to detect and investigate, reviewed according to risk |
| Fix a fault | Service, version, error code, and filtered context | Limited diagnostic window |
| Audit privileges | Actor, action, resource, and outcome | Period defined by risk and applicable obligations |
NIST SP 800-92 addresses log lifecycle management. It is a technical reference, not a rule that independently sets an organization's legal retention periods.
Rotation is not deletion. Renaming or compressing a file can leave it available indefinitely. Expiration must cover central indexes, local files, exports, queues, and backups according to their documented lifecycle. It is also necessary to check what happens when an old backup is restored.
Attacks discovered late raise a real objection: some investigations need historical records. Aggregate information or technical indicators can be retained longer after assessing whether they still identify people. If an incident requires evidence to be preserved, define the data set, the reason, access permissions, and when that exceptional retention will be reviewed.
Forensic integrity, deletion, and internal access
WORM storage—write once, read many—helps prevent alteration for a period of time. That protection must be designed alongside retention: locking a file full of unnecessary data for years creates a problem that can be difficult to resolve later.
When responding to a deletion request, locate the data and assess the legal basis and obligations that may justify retaining it. The right to erasure has limits and exceptions, but invoking “security” does not settle every case. A provider's immutable configuration does not by itself create a legal exception either.
When evidence should be retained, restrict its uses and access, document the reason, and plan for deletion when the need ends. When deletion is required, the architecture must make it possible. Choosing proportionate segments and lock periods reduces future conflicts.
Everyday access calls for the same discipline: individually assigned accounts, role-based permissions, and logging of queries and exports. Auditing who accesses logs helps detect misuse; those new records also need limits. Encrypting the repository protects its contents, but does not justify collecting more.
A practical limit on surveillance
From a classical liberal perspective, accumulating information about people concentrates power in the hands of those who can access it. Governments and companies alike can turn operational traces into tools for reconstructing habits or relationships. Limiting collection reduces that possibility by design.
This is an editorial reason to support minimization, alongside its technical and legal foundations. Trust should not rest solely on promises of proper use: it also needs verifiable limits on what is stored and who can see it.
Key idea: A log policy is verifiable when it can explain every field, demonstrate its access controls, and confirm that expired data is deleted.
A review can begin with a single access event: follow it from the application through its copies, remove secrets, justify identifiers, and test both investigation and deletion. That exercise turns a privacy statement into a concrete system capability.
Share