Article
· Jun 27 1m read

How to output audit logs programmatically (by user or event)

InterSystems FAQ rubric

You can use the List query of the %SYS.Audit to output audit logs programmatically.

The sample code is as follows:

 Set statement=##class(%SQL.Statement).%New()  
 Set status=statement.%PrepareClassQuery("%SYS.Audit","List")
 Set rs=statement.%Execute()  
 Set tab = $char(9)
 While rs.%Next() {    
   Write rs.%Get("TimeStamp")_tab_rs.%Get("Event")_tab_rs.%Get("Username"),!      
 }
Discussion (0)1
Log in or sign up to continue