Back to resources
Security & ComplianceApril 2024·Updated April 2024·13 min read

Audit Logging and Compliance for B2B Custom Software

Enterprise buyers ask about audit logs before they ask about your frontend framework. They need to know who changed a price, who exported customer data, who approved a shipment override, and whether those records are protected against tampering and retained for the required period. For many B2B products, auditability is not a compliance checkbox; it is part of the product capability that unlocks procurement. Audit logging for custom B2B software sits between security, operations, and product design. Done late, it forces expensive retrofits and leaves gaps during SOC 2 audits or customer security questionnaires. Done early with a clear event taxonomy, it supports production readiness, multi-tenant isolation, and enterprise integrations without bolting on a parallel logging system nobody trusts.

What enterprise buyers expect from audit trails

Security teams want tamper-evident, time-ordered records of security-relevant actions: authentication, authorization changes, data exports, configuration edits, API key lifecycle events, and admin impersonation. Compliance teams want retention aligned with policy, searchable evidence for investigations, and clear controls over who can read or export logs. Operations teams want business-meaningful events tied to workflows: approval granted, status transition, integration replay, or manual override with a reason code. Pure HTTP access logs rarely answer 'why did this order state change?' Procurement questionnaires repeat the same themes: log integrity, retention duration, access controls on logs, tenant isolation in multi-tenant setups, and export to a customer SIEM. Answering 'we will add it later' can delay deals.

  • Who acted: user, service account, API key, or support impersonation
  • What changed: before/after values or a structured diff
  • When: UTC timestamp and ordering semantics where required
  • Where: IP address, user agent, session ID, and tenant context
  • Why: reason code or ticket reference when humans override rules

Audit logs vs application logs vs metrics

Application logs help engineers debug: stack traces, query timings, cache misses. Metrics aggregate system health: error rates, latency, throughput. Audit logs establish accountability for customers and regulators. Mixing all three into one stream without a clear taxonomy makes SIEM ingestion more expensive and investigations noisier. Audit events should be append-only from the application's perspective: no in-place edits and no deletes outside governed retention processes documented in policy. Storage can be a database table, immutable object storage, or an event-bus consumer; the important requirements are tamper evidence, access control, and retention, not the brand of the tool. Separate hot search from cold archive when long retention is required: for example, keep the most recent 90 days searchable in the tenant admin UI and move older records to lower-cost archival storage.

Designing an event taxonomy early

Define event types with stable names: user.role_assigned, order.status_changed, integration.replay_requested. Namespace events by domain, version their schemas internally, and document required fields for each type. Capture actor and subject explicitly. The actor is the identity that performed the action; the subject is the entity affected. For actions performed on behalf of another user, such as delegation or support impersonation, record both actor and on_behalf_of when applicable. For configuration changes, store structured diffs and redact secrets. Never write passwords, API secrets, or full payment card numbers into audit payloads. Store the names of changed fields and masked previews where needed. Align the taxonomy with discovery workshops by asking compliance and security stakeholders which workflows require strong evidence during audits.

  • Catalog event types with an owner team and retention class
  • Define required metadata: tenant_id, actor_id, and correlation_id
  • Use human-readable labels for the admin UI and machine-readable codes for SIEM
  • Map domain events to compliance control frameworks where needed

Tenant isolation and admin visibility

In multi-tenant B2B SaaS, tenant administrators must see only their own audit trail. Platform operators may need cross-tenant views for abuse investigations, but those views require stronger access controls and their own audited actions. Support impersonation is high risk: log the start and end of impersonation sessions, the actions taken, and the associated ticket reference. Some customers prohibit impersonation entirely; document your model in your security materials. Row-level security on audit tables that mirrors application data isolation helps prevent a classic failure mode: correct application isolation combined with a support SQL console that can expose every tenant.

Audit expectations when integrating ERP and external systems

Integrations create two sides of the same state change: your application changed state and the ERP reflected it—or failed to. Log outbound integration attempts with correlation IDs matching ERP integration patterns, a payload hash or relevant key fields, response status, and reconciliation outcome. When customers replay or reverse transactions, record the reason code and link the new event to the original event ID. Month-end disputes often require a chain of evidence across systems; your audit trail should point to the relevant ERP document numbers. If integration is asynchronous, log enqueue, success, failure, and manual intervention. Silent retries without audit records leave operations blind.

GDPR, retention, and the right-to-erasure tension

EU customers will often ask how audit logs interact with GDPR. Personal data in logs—such as names, email addresses, and IP addresses—may require retention limits and deletion or anonymization processes that must be balanced against security, fraud-prevention, or contractual requirements. Legal should determine the applicable retention periods and legal basis for each category of data. Where legally appropriate, pseudonymize actor identifiers in long-term archives when events can remain useful without directly identifying the individual. Document what happens during tenant offboarding: export window, deletion schedule, and legal holds. Do not promise 'delete everything about user X' without reviewing audit storage, backups, immutable archives, and applicable legal obligations. Contracts and privacy documentation should describe the actual behavior.

SOC 2, ISO 27001, and customer security audits

SOC 2 Type II evaluates whether relevant controls operate effectively over time. Your audit design should support control narratives with evidence: access provisioning and deprovisioning, privileged actions, configuration changes, and alerts for suspicious activity such as unusual export volume. Customer audits may sample tickets and incidents. Show how you traced an incident using correlation IDs across application, audit, and integration logs. Practice this drill before sales promises that level of traceability. Third-party penetration tests often identify missing authorization logging on admin endpoints. Record important authorization failures in the security or audit event stream, not only successful privileged actions.

  • Periodic review of privileged role assignments with evidence
  • Alerting on bulk exports and API key creation
  • Documented retention and access policies for audit storage
  • Runbooks linking audit searches to incident-response steps

Implementation patterns that avoid painful retrofits

Emit audit events at the application service layer when business invariants change, not only in controllers. ORM hooks alone can miss changes performed by background jobs or other execution paths. Use an outbox or another transactional emission pattern so audit records are durably linked to the business transaction. Losing an audit record after the business transaction commits is a credibility killer. Expose a tenant-admin UI with filters for user, date, and event type, plus CSV export for customer compliance teams. Pagination and rate limits still apply; exports themselves should generate audit events. Plan audit implementation as part of the MVP when you sell to regulated or enterprise segments. Deferring it entirely usually costs more than implementing a focused two- to three-week slice during the initial build.

  • Emit at the service layer on business state transitions, not only at the HTTP layer
  • Use a transactional outbox so audit and business events are committed together
  • Separate retention classes for security events and routine configuration changes
  • Load-test the audit write path before bulk imports or migration weekends

SIEM forwarding and customer-owned observability

Enterprise customers increasingly ask to stream audit events into their Splunk, Datadog, or Microsoft Sentinel environments. Treat this as a product requirement with volume estimates, schema documentation, and a defined authentication model such as OAuth client credentials, HMAC-signed webhooks, or a syslog relay. Nightly batch exports are easier to ship but may not satisfy real-time detection or investigation requirements. Streaming adds operational burden: retry queues, dead letters, schema versioning, and customer-side parser breakage when you change the contract. Offer a stable JSON schema with additive versioning. Document rate limits and maximum payload size. Provide a bounded replay window for missed events after outages, subject to contractual retention. When forwarding includes PII, the data-processing agreements and subprocessor documentation should account for the SIEM path. Security review will ask whether the stream can leak cross-tenant data; partition streams by tenant or use separately authenticated delivery channels where contracts require it.

For smaller customers, CSV export from the admin UI plus documented read-only API endpoints may be sufficient initially. Sales should not promise SIEM integration on day one unless engineering has sized and load-tested the pipeline.

Audit trails operators and support teams actually use

Compliance officers read audit logs during investigations. Operators read them to answer 'what happened to shipment 4472?' Support teams read them during impersonation disputes. Each audience needs different UI affordances. Operators benefit from business identifiers in audit entries: order number, lot code, customer reference—not only internal UUIDs. Include stable external references in event payloads so searches match the way operational teams identify records. Support workflows should link audit entries to tickets and chat transcripts without duplicating sensitive content. A support agent should see that an override happened, who approved it, and the reason code, then jump to the relevant business record. Train customer administrators during onboarding on where audit logs live and which roles can export them. An undiscovered audit UI becomes shelfware, and renewals suffer when security questionnaires ask for evidence the buyer was never shown.

Audit checks before go-live

Add audit scenarios to go-live checklists: role changes, manual overrides, data exports, failed-login bursts, integration replays, and impersonation sessions. Verify tenant isolation by attempting cross-tenant access in staging and confirming that no data leaks through the UI or API. Validate retention jobs in staging, verify that backup restores include audit data, and load-test the SIEM forwarder—if it is part of the product—for volume spikes during bulk imports.

Next steps

List the ten actions your customer compliance officer is most likely to ask about. Map each to an event type today or mark the gap. Schedule a taxonomy review with engineering and legal before the next enterprise RFP. See other resources, enterprise delivery experience, book a call, or send a message with your tenant model, target compliance frameworks, and whether audit logging is a current gap or a launch requirement.

FAQ

When should audit logging be built into a B2B MVP?

If you sell to mid-market or enterprise buyers, include core audit events for critical workflows and administrative actions in the MVP. You can defer SIEM forwarding and advanced analytics, but tenant administrators should be able to see who changed critical records before the first paid pilot.

How long should audit logs be retained?

Retention requirements vary by contract, industry, and applicable law. Rather than choosing one global number, define documented retention tiers and make sure deletion, archival, and backup behavior are consistent with those requirements.

Can we rely on cloud provider audit logs only?

No. Cloud audit logs such as AWS CloudTrail primarily cover infrastructure and account activity, not business semantics. You still need application-level audit events for approvals, data exports, configuration changes, and other actions customers care about in disputes.

Should audit logs be searchable by end users or only admins?

Typically, access is limited to tenant administrators and designated compliance or security roles. Product-specific exceptions exist, such as shared-workspace activity logs. Document the role matrix in your security materials to avoid exposing sensitive actions too broadly.

How do audit logs affect application performance?

Audit writes can add latency when performed synchronously on hot paths. Use a durable transactional outbox or another reliable asynchronous pattern where appropriate, and batch lower-severity events when the business requirement allows it. Load-test approval workflows with audit enabled before promising SLAs. Storage growth also requires partitioning or tiered retention so queries remain fast.