Log database code

Posted on 2006-05-10
Last Modified: 2013-12-18
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?
Question by:navgup
    LVL 63

    Expert Comment

    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
    LVL 63

    Expert Comment

    In the Domino Help Search for

    Making a Log

    It has samples of your options.

    I hope this helps !
    LVL 63

    Accepted Solution

    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 )
      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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now