Sharepoint provides audit property for the objects that can be audited. Its pretty easy to turn on audit feature programmatically on any list/document library or a sitecolleciton by setting the values for the property. In the object model, for a SPList, SPListItem the audit property can be set on specific events so that it doesn’t generate huge data. Code as follows :
SPSite siteCollection = SPContext.Current.Site;SPWeb site = siteCollection.RootWeb;SPList docLib = site.Lists("DocLibName");
// Turn on auditing flags.
docLib.Audit.AuditFlags = SPAuditMaskType.View | SPAuditMaskType.ChildDelete;docLib.Audit.Update(); In the above example only view and delete events get audited, any more events to be audited can be added to audit flag separating Bitwise OR.
Auditing options:
SPAuditMaskType.CheckInSPAuditMaskType.CheckOutSPAuditMaskType.ChildDeleteSPAuditMaskType.CopySPAuditMaskType.DeleteSPAuditMaskType.MoveSPAuditMaskType.ProfileChangeSPAuditMaskType.SchemaChangeSPAuditMaskType.SearchSPAuditMaskType.SecurityChangeSPAuditMaskType.UndeleteSPAuditMaskType.UpdateSPAuditMaskType.ViewSPAuditMaskType.Workflow
No comments:
Post a Comment