Tip #45: How to implement item level audit

Rate this item
(0 votes)

SharePoint provides Auditing functionality to track what happening with sites, collections and farms via audit settings and policies . Unfortunately, there are no OOTB features, providing detailed item-level audit - how much times site items were viewed, copied, deleted and etc.

The good side is that SharePoint object mode provides you API to implement custom audit for your site items. Everything you need is to obtain a reference to an SPSite object for the current site collection, and then setting the proper audit flags on the Audit property of the SPSite object.

For example:

list.Audit.AuditFlags = SPAuditMaskType.All;
list.Audit.Update();

where SPAuditMaskType can take the the following enumeration values

SPAuditMaskType.CheckIn
SPAuditMaskType.CheckOut
SPAuditMaskType.ChildDelete
SPAuditMaskType.Copy
SPAuditMaskType.Delete
SPAuditMaskType.Move
SPAuditMaskType.ProfileChange
SPAuditMaskType.SchemaChange
SPAuditMaskType.Search
SPAuditMaskType.SecurityChange
SPAuditMaskType.Undelete
SPAuditMaskType.Update
SPAuditMaskType.View
SPAuditMaskType.Workflow

Source1, Source2

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.