[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Log database code

I m writing code to archive docs from one of my notes app. I need to log every docs that is being archived just as notes does logging in log.nsf. I can either use txt or rtf to store upto a certain limit of data (< 64k) and then create a new log document.

Can any one provide me with a sample code/db that i could start with?
0
navgup
Asked:
navgup
  • 3
1 Solution
 
SysExpertCommented:
There is bult in Log function in Lotus script.


A more detailed version I use is as follows.
I have a script library that as the following.


The Form has the fields defined as in the last entry.


Dim logDocx As NotesDocument
      ' changed global to Logdocx from logdoc 11/23/05

Dim curDbL As NotesDatabase
Dim sL As NotesSession
Sub Initialize
      Set SL= New NotesSession
      Set CurDbL = SL.CurrentDatabase
      
End Sub

Sub CreateLogEntry1(Msg As String, ERL1 As  String , ERNum As  String)
      ' changed global to Logdocx from logdoc 11/23/05
      Set logDocx = curDBL.CreateDocument()
      
      logDocx.Form = "Logfrm1" ' Form to use
      logDocx.DateLog = Now
      
      logDocx.StERL = ERL1
      logDocx.StERNum = ERNum
      logDocx.StStatus = "0"
      
      logDocx.StBy = SL.UserName
      logDocx.StDetails = Msg
      
      Call logDocx.Save(0,0)
            
End Sub
0
 
SysExpertCommented:
In the Domino Help Search for

Making a Log

It has samples of your options.

I hope this helps !
0
 
SysExpertCommented:
You can use LS or JAVA.

Here are LS examples

  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
  2.      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
  3.      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.
See Also
NotesLog class
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now