Logs you'll need at 2 a.m.
When an incident hits — a leaked credential, an unauthorized action, a refunded amount the model invented — the logs are the only ground truth. If they don't exist, you're guessing.
What to log per request
- Request id (unique, surfaced to the user for support).
- Authenticated user id (not just session token).
- Prompt version, model, sampler params.
- Full input (with PII handling per policy).
- Retrieved chunks / tool calls / tool returns.
- Reasoning trace (where available).
- Final output, output filter flags.
- Downstream actions taken (with idempotency keys).
Storage and retention
Logs need retention long enough to investigate and short enough to comply with privacy. Encrypt at rest. Make raw logs accessible only to incident responders; aggregate metrics broadly available.