SearchHttpStringInLog.lss; %REM App:Docu.nsf Pro:SearchHttpStringInLog Now:2012.10.04.12.51.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 ono that session ServerName = Sess.CurrentDatabase.Server 'Add query String... SearchCriteria for specific errors Dim srchCriteria (7) As String srchCriteria(0)= "java.lang.NullPointerException" srchCriteria(1)= ": javax.faces." ' the colon is added to ensure we are getting ' the right faces error (see applog.nsf info) srchCriteria(2)= "Couldn't instantiate" srchCriteria(3)= "NotesException: Method is not available" srchCriteria(4)= "Couldn't find design note" srchCriteria(5)= "Full text operations on database" srchCriteria(6)= "Lotus Notes Exception - Invalid or nonexistent document" 'initialize variable for viewName DocView = "MiscEvents" 'initialize variable for Logdb Name DatabaseName = "applog.nsf" 'TO DO: Revive this Integer(Count) for testing purposes 'initialize variable for Count RecordsCount = 0 '[add RecordCounts here To uniquely identify values] 'Set up name for the text file being created FileName = ServerName & "LOGNSFMULTHTTPERRORSTYPE" 'Set up placeHolder for the text file being created 'FileName = "C:\temp\TXT_DATA\" & Filename &".txt" 'Set up placeHolder for the text file being created FileName = "C:\temp\CSV_DATA\" & Filename &".csv" 'Initialize freeFile placeholder RecordsFreeFile = FreeFile() 'use placeholder to load data/documents in File Open FileName For Output As #RecordsFreeFile 'yank HTTP JVM values from this database Set ServerLog = New NotesDatabase(ServerName, DatabaseName) 'HTTP JVM list of items are contained in this view Set DBView = ServerLog.GetView(DocView) 'TO DO: Add an entry here to see if the document is actually new 'Still set up this database in 'Agent Properties' to grab values 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 first document Set LogDoc = DBView.GetFirstDocument 'run through this list (EventList) until last row in the document is reached 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, get results based on number of days 'you want returned to thr program to creat the textFile '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