An audit record should capture who, what, when, where, and the business correlation: actor ID, action, entity type/ID, UTC timestamp, tenant, request ID, and safe before/after values. Write it in the same transaction as the change when omission is unacceptable. Example fields: Audit(Id, RestaurantId, OutletId, ActorId, Action, EntityType, EntityId, OccurredAtUtc, CorrelationId, BeforeJson, AfterJson) Make the log append-only with tightly restricted access and tamper-evidence or immutable storage for high-risk systems. Redact secrets, tokens, payment data, and unnecessary personal data. Index tenant/time/entity queries, define retention, and distinguish audit events from diagnostic logs. Capture the authenticated actor and tenant server-side, not from request payloads.
Backbencher Developer · · 0 likes