Share via


SPAudit.WriteAuditEvent Method (String, String, String)

Writes a record about an event to the SharePoint database.

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

Syntax

'Declaration
Public Function WriteAuditEvent ( _
    eventName As String, _
    eventSource As String, _
    xmlData As String _
) As Boolean
'Usage
Dim instance As SPAudit
Dim eventName As String
Dim eventSource As String
Dim xmlData As String
Dim returnValue As Boolean

returnValue = instance.WriteAuditEvent(eventName, _
    eventSource, xmlData)
public bool WriteAuditEvent(
    string eventName,
    string eventSource,
    string xmlData
)

Parameters

  • eventName
    Type: System.String

    The kind of event being recorded.

  • eventSource
    Type: System.String

    The name of the calling application.

Return Value

Type: System.Boolean
true in all cases.

Remarks

Use this method to write records of custom events when you have multiple kinds of custom events and need the event record to be more specific than just "custom". Pass the name of one of your custom event types for eventName. Pass the name of your SharePoint solution as eventSource. Optionally, pass up to 4000 characters of additional information about the event as xmlData.

You can use any XML schema you want to format xmlData, or you can use undefined XML. However, when you are including data that is essentially the same as event data that SharePoint Foundation uses in its built-in events, reading and processing your database records is easier if you use the same tags. For example, if your event data refers to an object other than the one on which the event was raised, use the pattern <RelatedItem><Id>GUID_of_other_object</Id><Relationship>some_relationship</Relationship></RelatedItem>, which is similar to what SharePoint Foundation uses for ChildDelete events. See the topic for SPAuditEntry.EventData for more information on the XML tags that SharePoint Foundation uses.

See Also

Reference

SPAudit Class

SPAudit Members

WriteAuditEvent Overload

Microsoft.SharePoint Namespace

Other Resources

Item-Level Auditing with SharePoint Server 2007