Arviser

LLM logging without storing sensitive prompts

Short answer: log the shape of each request and keep the text out by default. Record identifiers, versions, counts, timings, tool names and verdicts on every call, and store raw prompt text only in a small, consented sample with a short retention window. Engineering can still debug and score the system, and personal data stays at the minimum the purpose needs.

This guide is for the engineering lead who owns the traces and the privacy owner who signs off on them. It describes engineering practice and is not legal advice.

What should every LLM log record contain?

Short answer: enough to answer three questions without reading the prompt. Which version served the request, what did it cost in tokens and time, and did any control fire. Identifiers, versions, counts and verdicts answer all three.

Most debugging starts with a version question. If each record carries the model, prompt template and retrieval versions, you can slice by version and find the change behind a drop. Production sampling relies on the same labels.

Field Default Retention (example) Note
Request id Keep Log window Joins the trace
Tenant id Keep as keyed hash Log window Raw id stays in the tenant table
Model name and version Keep Log window The resolved version behind the alias
Prompt template version Keep Log window A version label, never the filled prompt
Retrieved document ids Keep ids, drop text Log window The text already lives in the index
Token counts in and out Keep Log window Feeds cost per task
Latency per step Keep Log window Feeds p95 budgets
Tool calls Keep name and argument shape, redact values Log window Types and lengths, not contents
Guardrail verdicts Keep Log window Rule id and outcome
User feedback flag Keep flag, drop free text Log window Free text only in the sample
Raw prompt and answer text Drop, except in the sample Short, for example 7 to 30 days Needs consent and a named purpose

The retention values are examples. Your privacy owner sets the real ones next to the purpose for each field.

How do I sample raw text with consent?

Short answer: treat raw text as a separate store with its own rules. Sample a small share of conversations from users who agreed to it, keep them for a short, fixed period, and delete them on schedule.

Quality work needs some text, since a judge cannot score groundedness from token counts. Keep that need small and visible:

Data minimisation and retention limits are general principles you can design to. Whether a given sample is lawful is a question for counsel.

How should I hash and redact fields?

Short answer: hash identifiers you need to join on, and redact values you only need the shape of. Use a keyed hash, with the key held outside the logging system, so nobody can reverse a short id by hashing guesses. Redact by type, and record what was removed, so the log still shows that an email or an account number was present.

For tool calls, log the argument shape. A call to lookup_invoice with one 12-character string shows the agent used the right tool with the right type. The invoice number adds risk and little debug value.

Redact before storage. Run it in the process that writes the log, so raw values never reach the log pipeline or a third-party tracing service.

Who should be able to read the logs?

Short answer: fewer people than can read the application database. Split metadata logs from the raw text sample, give each its own role, and log every read of the sample store. On-call engineers usually need metadata only.

In multi-tenant systems, a reviewer tool that loads samples across tenants can show one customer's text to staff serving another. Cross-tenant retrieval covers the same boundary for retrieval.

How do I delete logs when a user asks?

Short answer: design deletion before launch. Every record that can hold personal data needs a key you can find it by, usually the hashed user or tenant id. One job then removes them from the metadata store, the text sample, the golden set and any vendor copy.

Test it with a synthetic user. Generate traffic, request deletion, and check each store, backups included. Write down how long each store takes to clear.

What does a minimal log record look like?

Short answer: a flat record with ids, versions, counts and verdicts, and no user text. This synthetic example describes no client system.

{
  "request_id": "req_7f3a91",
  "tenant_hash": "hk_2b9c44e1",
  "model": "provider-model-2026-09-01",
  "prompt_template": "support_answer@v14",
  "retrieval_index": "kb@2026-11-12",
  "retrieved_doc_ids": ["doc_118", "doc_402"],
  "tokens_in": 1840,
  "tokens_out": 212,
  "latency_ms": { "retrieval": 140, "model": 1930, "total": 2160 },
  "tool_calls": [
    { "name": "lookup_invoice", "args_shape": { "invoice_id": "string(12)" } }
  ],
  "guardrails": [
    { "rule": "pii_output", "verdict": "pass" },
    { "rule": "injection_input", "verdict": "flag" }
  ],
  "feedback": "thumbs_down",
  "in_text_sample": false
}

A flagged injection verdict is a signal a kill switch trigger can watch. AI security risks and the OWASP LLM Top 10 for 2026 describe the attacks those rules look for.

LLM logging checklist

Next: Production sampling · Kill switch · AI security risks · OWASP LLM Top 10 2026 · Threat modeling RAG · Cross-tenant retrieval · Shared metrics · Cost and latency gates

For an outside review of what your traces hold and how they feed quality scoring, see the LLM Quality Audit.

Request a quality audit scope