Find Errors in Notes Log

This tip is useful to automatically scan the Notes Logs on servers for keywords that indicate errors. Results are e-mailed to the user indicated in the script.

View member feedback to this tip.

This tip is useful to automatically scan the Notes Logs on servers for keywords that indicate errors. Results are e-mailed to the user indicated in the script.

'Find errors: 

'This agent searches today's documents in server logs (log.nsf) for particular words that indicate errors.
'A list is generated and inserted into a mail message that is sent to the current user.
'Add the agent to a database on the server and schedule it to run daily. 
'Make sure that the agent signer has rights to read the Notes Log.

Option Public

Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim mailDb As NotesDatabase
Dim mailDoc As NotesDocument
Dim dt As String
Dim item As NotesItem
Dim rtitem As NotesRichTextItem
Dim rtStyle As NotesRichTextStyle
Const ADMIN = "Your Administrator"

Sub Initialize
 Dim s As New NotesSession
 REM Words to search log for. Increase array 
bounds and add more words if needed.
 Dim srch (4) As String
 srch(0) = "unable"
 srch(1) = "error"
 srch(2) = "fail"
 srch(3) = "ATTEMPT"
 srch(4) = "invalid"
 REM Servers' logs to search. Increase array
 bounds and add more servers if needed.
 Dim srv (3) As String
 srv(0) = "Svr1"
 srv(1) = "Svr2"
 srv(2) = "Svr3"
 srv(3) = "etc"
 REM Set up  today's date and format 
 dt = Format(Date$, "mm/dd/yyyy")
 REM Create mail memo to hold output from server log    
 Dim db As NotesDatabase
 Set db = s.GetDatabase("", "names.nsf", False)
 Set mailDoc = New NotesDocument( db )
 Set rtitem = New NotesRichTextItem( mailDoc, "Body")
 Set rtStyle = s.CreateRichTextStyle
 Dim msg As String
 msg = "Search Keywords: "
 Forall w In srch
  msg = msg & { "} & w & {"}
 End Forall
 Call rtitem.AppendStyle(rtStyle)
 Call rtItem.AppendText( msg )
 rtStyle.Bold = False
 Call rtitem.AppendStyle(rtStyle)
 Call rtitem.AddNewline(2)
 REM Process for every server
 Forall m In srv
  Print "Searching Notes Log on " & m
  Set db = s.GetDatabase( m, "log.nsf")
  Call rtitem.AddNewline(1)  
  rtStyle.Bold = True 
  Call rtitem.AppendStyle(rtStyle)
  Call  rtitem.AppendText("Log for " & db.Server)
  rtStyle.Bold = False
  Call rtitem.AppendStyle(rtStyle)
  Call rtitem.AddNewline(2)
  REM Process for each search word in one server's log
  Forall e In srch
   Set dc = db.FTSearch( dt , 0)
   Call dc.FTSearch(e, 0)
   REM Process if any words are found
   If dc.Count > 0  Then
    REM Process the list of docs containing the 
search word and add them to mail message    
    Call FindErrors( dc , e)
   End If
  End Forall  'process next search word
 End Forall  'process next server 
 REM Send report to admin
 If Not mailDoc Is Nothing Then
  mailDoc.Form = "Memo"
  mailDoc.From = "Notes Error Log Report"
  mailDoc.Subject = "Error Report from Notes Logs"
  Call mailDoc.Send(False, ADMIN)
 End If
End Sub
Sub FindErrors
( coll As NotesDocumentCollection, srctxt As String)
 For i = 1 To coll.Count
  Set doc = coll.GetNthDocument(i)
  Set item = doc.GetFirstItem("EventList")
  Forall v In item.Values
   'Msgbox v
   chk = Instr(1, v, srctxt, 5)
   If Not chk = 0 Then
    'Msgbox v
    Call rtitem.AppendText( v )
    Call rtitem.AddNewline(1)
   End If
  End Forall
End Sub


Whenever I run this tip I get the following error message:
Object Variable not set:

I assume the only things I have to set are:
Administrator email address
SVR = server
srch = keyword

—A. Wilkie


The agent as posted is designed to be installed in a server database and scheduled to run on a server. The user is apparently running it on a Notes client which will generate this error. I run it on a schedule from the server so I can have my report first thing in the morning.

However, I also have a modified version that can be added to the user's mail database and launched from the Notes client when he is in the mail file. To view this version of the tip, click here.

—Mike Long, tip author

Do you have comments on this tip? Let us know.

Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was last published in April 2005

Dig Deeper on Lotus Notes Domino Agents

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...