%SYS.Audit
Class %SYS.Audit Extends (%Persistent, %SYSTEM.Help, %XML.Adaptor) [ Inheritance = right, StorageStrategy = Audit, System = 4 ]
The auditing system allows the user to capture events which occur on the system, and log them to an audit file.
When running SQL queries on the audit log, it is helpful to use the UTCTimestamp in the WHERE clause to speed up the query, and minimize the amount of data which is returned. For example:
SELECT SystemID,AuditIndex,UTCTimeStamp,EventSource,EventType,Event,Pid,CSPSessionID,Username,Description
FROM %SYS.Audit
WHERE UTCTimeStamp BETWEEN :UTCBeginDateTime AND :UTCEndDateTime
ORDER BY UTCTimeStamp DESC, SystemID DESC, AuditIndex DESC
The UTCTimeStamp is the UTC time in ODBC format. To convert a local $H time to this format use the following:
s x=##Class(%SYS.Audit).ConvertLocalHToUTC($H)
The UTCTimeStamp which is returned as part of the record, can be converted to local time with the following:
s x=##Class(%SYS.Audit).ConvertUTCToLocal(UTCTimeStamp)
Access to all the audit class methods require the %Admin_Secure:"Use" privilege.
If you wish to modify an audit record, use the Modify() class method. If you wish to modify it using direct object you must first use the OpenAuditRecord() class method and then the %Save() method. Note that saving the object in this way also requires that the user have write access to the Audit database resource.