SPAudit.GetEntries Method (SPAuditQuery)

Gets a collection of SPAuditEntry objects from the audit data stored in the SharePoint database that match the specified query.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No


Public Function GetEntries ( _
    query As SPAuditQuery _
) As SPAuditEntryCollection
Dim instance As SPAudit
Dim query As SPAuditQuery
Dim returnValue As SPAuditEntryCollection

returnValue = instance.GetEntries(query)
public SPAuditEntryCollection GetEntries(
    SPAuditQuery query


Return Value

Type: Microsoft.SharePoint.SPAuditEntryCollection
An SPAuditEntryCollection that holds the requested SPAuditEntry items.


Exception Condition

The calling code is in the context of a user who is not a site administrator.


query is a null reference (Nothing in Visual Basic).


For a simpler method that does not require you to create an SPAuditQuery object, see GetEntries.


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

SPSite oSiteCollection = (SPSite)properties.Feature.Parent;
SPAuditQuery oAuditQuery = new SPAuditQuery(oSiteCollection);
SPAuditEntryCollection collAuditEntries = oSiteCollection.Audit.GetEntries(oAuditQuery);

foreach (SPAuditEntry oAuditEntry in collAuditEntries) {
  // get info from audit log
Dim oSiteCollection As SPSite = CType(properties.Feature.Parent, SPSite)
Dim oAuditQuery As New SPAuditQuery(oSiteCollection)
Dim collAuditEntries As SPAuditEntryCollection = oSiteCollection.Audit.GetEntries(oAuditQuery)

For Each oAuditEntry As SPAuditEntry In collAuditEntries
  ' get info from audit log
Next oAuditEntry

See Also


SPAudit Class

SPAudit Members

GetEntries Overload

Microsoft.SharePoint Namespace

Other Resources

Item-Level Auditing with SharePoint Server 2007