SPAuditQuery class

Defines a query of the audit entries of the SharePoint database.


Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Public NotInheritable Class SPAuditQuery
Dim instance As SPAuditQuery

The fundamental scope of any query is always a site collection; but you can use the members of the class to restrict a query to particular date ranges, users, event types, lists, and list items.

This class is primarily used as a parameter to the GetEntries(SPAuditQuery) method.

You cannot use this class to query the SharePoint database for anything other than the records of audited events.

The following example (from Item-Level Auditing with SharePoint Server 2007) shows this class in use.

Dim wssQuery As New SPAuditQuery(siteCollection)
Dim auditCol As SPAuditEntryCollection = site.Audit.GetEntries(wssQuery)

For Each entry As SPAuditEntry In auditCol
  ' get info from audit log
Next entry

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.