NotesLog Class

Use the NotesLog class in LotusScript® and in Java agents that run in the background. Add the NotesLog class to your agent code to record run-time information. It is particularly helpful for capturing variable values, error handling, and verifying code logic. By default, the NotesLog class records information to the Agent Log. When you set up items you want recorded, make sure you don't exceed the Agent Log limit.

To use NotesLog, follow this LotusScript® example that tracks the documents an agent is processing by capturing the documents' subject. The information is recorded in the Agent Log.

Dim Dim agentLog As new NotesLog("Agent log")
Dim collection As NotesDocumentCollection
Dim db As NotesDatabase
Dim s As NotesSession
Dim count As Integer
Call agentLog.OpenAgentLog
Set s=New NotesSession
Set db = s.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set note = collection.GetFirstDocument
count = collection.Count
Do While (count >0)
Subject = note.Subject
Call agentLog.LogAction("Processing:"+Subject(0))
Set note = collection.GetNextDocument(note)
count = count-1
Loop
Call agentLog.Close

Agent Log limit

The Agent Log can hold only 64KB of information. When the information written to it exceeds this limit, the following message is displayed and the agent stops running:

Error executing agent <agent-name> in <database-name>. Memory allocation request exceeded 65,000 bytes.

Make sure that the information you want recorded to the Agent Log does not exceed this limit. If it does, rework the NotesLog class code to record less information per run.