AutoPurge for OpenLog

We are using the OpenLog logging framework written by Julian extensively in our applications but in logging intensive applications or when running with our custom DEBUG-level enabled you can generate a lot of logging documents. Cleaning these up should preferably be done automatically on a scheduled basis so I wrote a small agent to purge log documents older than 6 months and thought I would share:

Sub Initialize
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim dc As NotesDocumentCollection
   Dim dt As NotesDateTime

   Set dt = New NotesDateTime(session.International.Today)
   Call dt.AdjustMonth(-6)
   Set db = session.CurrentDatabase
   Set dc = db.Search(|Form="LogEvent" & LogEventTime<@TextToTime("| + dt.DateOnly + |")|, Nothing, 0)

   Call dc.RemoveAll(True)
End Sub

Really simple and nothing much to it…

2 thoughts on “AutoPurge for OpenLog”

Comments are closed.