← Resources
By Leila Haddad
— Solutions Architect, Enterprise
·
· GUIDE
AI Audit Logging and Compliance: What to Log and Why
AI systems need audit logs that ordinary application logging doesn't provide — for accountability, compliance, and litigation. This guide covers what to log, the frameworks that require it, why agent observability is uniquely hard, and the immutability and eDiscovery realities.
Why AI needs its own audit logging
AI agents take real actions and behave non-deterministically — the same prompt can produce different tool-call sequences across runs — so traditional, deterministic observability can tell you that something failed but not why. Worse, identity attribution is murky: agents often act under shared service accounts or a deploying human's credentials, so without per-action logging you can't cleanly tie an action to the agent that took it.
The result is an accountability gap exactly where the stakes are highest — autonomous actions on real systems. Audit logging closes it, and it's increasingly not optional: it's the evidence regulators, auditors, and courts ask for. (It also surfaces the excessive-agency risks covered in our [agent guardrails guide](/articles/autonomous-agent-guardrails).)
What to log
Application logs record requests; AI audit logs need to record the reasoning chain. Capture, as structured event records rather than aggregate metrics: the exact prompt and the response, every tool call with its inputs and outputs, the model name and version, the prompt version, the retrieved context, the user identity, token counts and cost, latency, and any escalation or human-approval event.
The model-and-version field matters more than people expect — when behavior changes after a model upgrade, you need the logs to show which version produced which output. Tie every record to an identity so the trail answers "who did what, with which model, when."
The frameworks that require it
Several regimes now make AI logging a requirement, not a nicety. The EU AI Act (Article 12) requires high-risk AI systems to automatically record events over the system's lifetime for traceability. GDPR's accountability principle obliges you to demonstrate compliance with documented evidence. HIPAA mandates audit controls over systems touching protected health data, with multi-year retention. SOC 2 doesn't prescribe a period but audits you against your own policy and expects tamper-evidence. And the NIST AI Risk Management Framework emphasizes documentation, auditability, and traceability — including model-change and data-versioning logs — across the lifecycle.
The common thread: log automatically, tie to identity, and be able to produce it.
Immutability and retention
Logs you can quietly edit aren't evidence. The standard is immutability — append-only or write-once storage, or cryptographic hash-chaining where each entry hashes the previous so any tampering is detectable — kept separately from the system that generated it, so even administrators can't retroactively alter it.
Retention varies by regime: HIPAA expects roughly six years, while SOC 2 commonly defaults to about twelve months (with a hot window for active investigation), audited against your stated policy. Set the retention to the strictest framework you're subject to, and make sure the storage enforces it rather than relying on process.
The observability gap and eDiscovery
Two newer pressures shape AI logging. First, standards: the OpenTelemetry GenAI semantic conventions are emerging as a common schema for AI telemetry — standardizing attribute names for model calls, token usage, and agent steps — so logs aren't locked to one vendor. Pair logging with anomaly detection to catch out-of-policy tool use and permission escalation that static logs alone won't flag.
Second, litigation: AI prompts and outputs are discoverable electronically stored information, and courts have already compelled production of large volumes of GenAI logs. That cuts both ways — your AI interaction history is a discovery liability and a legal-hold obligation, which means you need it searchable and producible, not scattered across systems.
Audit logging in osFoundry
osFoundry treats audit logging as a first-class enterprise capability, not a bolt-on. Every AI interaction — prompts, responses, tool calls, model and version, user, cost, and escalations — is captured as structured, traceable records tied to identity, directly addressing the agent observability gap and the EU AI Act's automatic-logging mandate. Built-in tool-call auditing and anomaly detection surface the excessive-agency and permission-escalation risks at the tool layer, while immutable retention supports SOC 2, HIPAA, and GDPR accountability expectations. Compliance reports map this evidence to recognized frameworks, and eDiscovery support makes AI interaction history searchable and producible for legal hold — so accountability for autonomous AI comes from one platform rather than stitched-together observability and governance tools. It pairs naturally with [SSO and RBAC](/articles/sso-rbac-for-ai-workspaces), since every logged action ties back to a governed identity.
Frequently asked questions
- Why does AI need audit logging beyond normal application logs?
- Because AI agents take real actions and behave non-deterministically, so ordinary logs can show that something failed but not why, and identity is often ambiguous (shared service accounts). AI audit logs record the full reasoning chain — prompts, tool calls, model version, and outputs tied to a user — which is what accountability, compliance, and incident investigation require.
- What should an AI audit log capture?
- The exact prompt and response, every tool call with inputs and outputs, the model name and version, the prompt version, retrieved context, the user identity, token counts and cost, latency, and any escalation or approval event — stored as structured event records, not just aggregate metrics. The model-and-version field is especially important for diagnosing behavior changes after upgrades.
- Does the EU AI Act require AI logging?
- Yes, for high-risk AI systems. Article 12 requires them to automatically record events over the system's lifetime to enable traceability and post-market monitoring — automatic logging, not manual documentation. Other frameworks (GDPR accountability, HIPAA, SOC 2, NIST AI RMF) impose related logging and evidence obligations.
- How long must AI audit logs be retained, and must they be immutable?
- Retention depends on the framework — HIPAA expects roughly six years, SOC 2 commonly defaults to about twelve months audited against your own policy. Immutability is the standard: append-only or hash-chained storage kept separate from the generating system, so logs can't be retroactively altered and any tampering is detectable.
- Which compliance frameworks require AI logging?
- The EU AI Act (Article 12 automatic logging for high-risk systems), GDPR (the accountability principle and records of processing), HIPAA (audit controls with multi-year retention), SOC 2 (logging audited against your policy with tamper-evidence), and the NIST AI Risk Management Framework (documentation and traceability across the lifecycle).
- Why don't traditional observability tools cover AI agents?
- Because they were built for deterministic systems. AI agents are non-deterministic — the same input can yield different tool-call sequences — and their identity attribution is often ambiguous. Traditional tools capture that a failure occurred but not the reasoning path that led there, which is the observability gap AI-specific, event-level audit logging fills.
- Are AI chatbot prompts and outputs discoverable in lawsuits?
- Yes. AI prompts and outputs qualify as electronically stored information subject to discovery, and courts have already compelled production of large volumes of GenAI logs. That makes your AI interaction history both a discovery liability and a legal-hold obligation — a strong reason to keep it logged, searchable, and producible rather than ephemeral.
Sources