Technical Guide

Redacting PII Before or After Writing LLM Audit Logs: Tradeoffs Between Auditability, Privacy, and Security

Neither placement is correct on its own. Redacting before the log is written reduces stored PII and exposure but can remove evidence you need later. Redacting after the write preserves fidelity but creates a raw store that needs strict access, retention, and deletion controls.

Redaction placement is a pipeline design decision

Most enterprises should decide per record type (prompt, retrieved context, tool-call arguments, model output) and combine patterns, for example pseudonymizing before write and keeping controlled re-identification for authorized investigations.

In short: the choice is not pre-write or post-write for the whole log. It is a decision made for each record type, with the patterns combined where needed.

Pre-write, post-write, and hybrid patterns compared

Where redaction can sit in the logging path

Redaction placement patterns for LLM audit logs
PatternHow it worksTradeoff
Pre-write Redact or tokenize at the gateway or tool-call layer, before anything is persisted. Reduces stored PII and exposure but can remove evidence you need later.
Post-write Store raw records in a restricted tier, then redact in downstream processing. Preserves fidelity but creates a raw store that needs strict access, retention, and deletion controls.
Hybrid Pseudonymize before write, keep the mapping separately, and gate re-identification. Keeps controlled re-identification available for authorized investigations.

Detection limits shape every placement

Every placement depends on detection, so the log should report how well detection performs and what happens when it fails.

Require reported detection error rates and a defined behavior when detection fails.

Decision criteria for choosing or combining patterns

Make the decision separately for each record type: prompts, retrieved context, tool-call arguments, and model outputs. The tradeoffs above translate into these criteria:

  • Stored PII and exposure: pre-write redaction reduces both, at the cost of evidence you may need later.
  • Evidence fidelity: post-write redaction preserves it, but the raw store needs strict access, retention, and deletion controls.
  • Authorized investigations: a hybrid pattern pseudonymizes before write and keeps controlled re-identification available.

Audit log properties to require

These are runtime controls in the logging path. Whichever pattern you choose, the audit log should provide the following:

  • Redaction placement configurable per record type: prompts, retrieved context, tool-call arguments, and model outputs.
  • Tamper-evident records, with integrity checks that remain meaningful after redaction or deletion events.
  • Role-based access to any raw tier, with access itself logged.
  • Defined retention limits and deletion workflows for raw and pseudonymized data.
  • Authorized, logged re-identification workflows if tokenization or pseudonymization is used.
  • Reported detection error rates and a defined behavior when detection fails.

Review your AI audit logging design

Discuss how runtime policy enforcement and audit logging fit your redaction and retention requirements.

Talk to an Expert