I have a requirement where I have to put audit log feature in an existing Asp.net Web Forms application in C# using SQL Server 2008. There are various pages in this application which use from formviews, listviews, gridviews for inserting, updating and deleting data. The requirement is to capture each 3 of these events with data which was modified/deleted, the user details and timestamp.
I want ideas/suggestions as to how I can easily implement this (the code in the application side) and with the use of just one AuditLog table (database side). This is my initial design of the table:
- AuditId uniqueidentifier
- TableName varchar(100)
- RecordId varchar(100) (some tables have int as primary and some have guid)
- Action char(1) (I - insert, U - update, D - delete)
- RecordData varchar(MAX) (dump all data for that record, not sure about this field, need help??)
- ActionDate datetime
- ActionedBy varchar(20) (user)
Thanks in advance...