Skip to main content

Examples: NotesLog class

  1. This script opens a mail message for logging and mails it to Jimmy Ho.
Sub Initialize
Dim currentLog As New NotesLog( "Checkup Agent" )
Call currentLog.OpenMailLog( "Jimmy Ho", _
"Log for Checkup Agent" )
Call currentLog.Close
End Sub

The mail message contains the following in the Body item:

04/26/95 12:19:40 PM Checkup Agent starting

  1. This script opens a mail message for logging. It then logs one action for each document found in the current database, and mails the message.
Sub Initialize
Dim currentLog As New NotesLog( "Cleansing Agent" )
Call currentLog.OpenMailLog( "Jimmy Ho", _
"Log for Cleansing Agent" )
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.AllDocuments
Set doc = collection.GetFirstDocument
count% = 0
While Not ( doc Is Nothing )
count% = count% + 1
Call currentLog.LogAction( "Processed document " + _
Cstr( count% ) )
Set doc = collection.GetNextDocument( doc )
Wend
Call currentLog.Close
End Sub

If there are four documents in the database, Jimmy Ho receives a mail memo that contains the following in the Body item:

04/26/95 10:50:17 AM Cleansing Agent starting 04/26/95 10:50:17 AM Processed document 1 04/26/95 10:50:17 AM Processed document 2 04/26/95 10:50:17 AM Processed document 3 04/26/95 10:50:17 AM Processed document 4

  1. This script opens a Domino® database for logging. If it can't find the "All by Category" view in the current database, it logs an error.
Sub Initialize
viewName$ = "All by Category"
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim agent As NotesAgent
Dim currentLog As NotesLog
Set db = session.CurrentDatabase
Set agent = session.CurrentAgent
Set currentLog = New NotesLog _
( agent.Name + " Agent in " + _
db.Title + " on " + db.Server )
Call currentLog.OpenNotesLog( "", "agentlog.nsf" )
Set view = db.GetView( viewName$ )
If view Is Nothing Then
Call currentLog.LogError _
( 0, "Unable to find view " + viewName$ )
End If
Call currentLog.Close
End Sub

One new document gets created in the AGENTLOG.NSF database, containing the log name, the current date and time, the error code, and error description.