%REM App:Docu.nsf Pro:SearchComStringInLog Now:2012.9.08.2.02.AM Sys:Dököll Solutions, Inc. Des:LotusScript Agent created from copy to read Log.nsf database and load results into text file :Agent should be set up to load new documents only, avoid loads in file/servers. See Agent properties... %END REM Option Public Sub Initialize 'Declare database variables Dim ServerLog As NotesDatabase Dim Sess As NotesSession Dim ServerName As String Dim DBView As NotesView Dim DocView As String Dim DatabaseName As String 'Declare fileGrab variables Dim RecordsPosition As Long Dim RecordsCount As Long Dim Filename As String Dim RecordsFreeFile As Integer 'Declare Search variables Dim SearchCriteria As String Dim LogDoc As NotesDocument 'Get a Notes session Set Sess = New NotesSession 'Grab the Server Name based on session ServerName = Sess.CurrentDatabase.Server 'Declare and initialize Array (query items) Dim srchCriteria (5) As String srchCriteria(0)= "at com.ibm." srchCriteria(1)= "at com.sun." srchCriteria(2)= "at javax.faces." srchCriteria(3)= "at java.security." srchCriteria(4)= "at lotus.domino." srchCriteria(5)= "at java.lang." 'Declare and initialize variable for viewName DocView = "MiscEvents" 'Declare and initialize variable for Logdb Name DatabaseName = "applog.nsf" 'TO DO: Revive this Integer(Count) for testing purposes RecordsCount = 0 'Set up name for the text file being created FileName = ServerName & "LOGNSFMULTCOMERRORSTYPE" 'Set up placeHolder for the text file being created FileName = "C:\temp\CSV_DATA\" & Filename &".csv" 'Initialize freeFile placeholder RecordsFreeFile = FreeFile() 'use placeholder, load data in FileName Open FileName For Output As #RecordsFreeFile '... Set ServerLog = New NotesDatabase(ServerName, DatabaseName) '... Set DBView = ServerLog.GetView(DocView) 'TO DO: Add an entry here to see if the document is actually new 'Still set up this database 'Agent Properties' from applog.nsf 'this should help avoid creating a truly large text file (enhances performance) 'Further, query the back-end (applog.nsf) with a dateRange, in which case you may need to index 'the applog.nsf database so it is searchable 'Grab the first document Set LogDoc = DBView.GetFirstDocument 'run through this list (EventList) until last cursor in the documents list While Not LogDoc Is Nothing 'TO DO: Add a dateRange here to minimize the load in your textFile 'Alternatively, you can DateDiffer against LogDoc.Created 'and count days from LogDoc.Created to search entries on 'pick any logItems created from EventList If LogDoc.Created Then 'read records sequentially from eventList ForAll LogRecords In LogDoc.EventList ForAll errDescrip In srchCriteria 'search the value SearchCriteria through the records returned from eventList RecordsPosition = InStr(LogRecords, errDescrip) 'if found HTTP is found, fill in RecordsFile If RecordsPosition > 0 Then 'Print the records into the text (RecordsFile) file Print #RecordsFreeFile,LogRecords '[add RecordCounts here to uniquely identify values] 'increment the RecordsCount and loop through until end of the textfile (newly created) RecordsCount = RecordsCount + 1 End If End ForAll End ForAll End If 'Get the remaining docs sequentially from eventList, if any Set LogDoc = DBView.GetNextDocument(LogDoc) Wend 'close the file Close #RecordsFreeFile 'TO DO: Revive this messageBox for testing purposes MessageBox "Number of Records Searched " & RecordsCount & " based on Search Criteria" End Sub