Skip to main content

Support & downloads  >  

Lotus Education On Demand: Logging Notes Application Activity

 Education
 
Abstract
Introduction to Logging Application Activity
A NotesLog object can be used to record actions and errors that occur in scripts. This information can be stored in one of the following ways:
---Notes database
---Mail memo
---Text file (local scripts only)

In this Learning Byte, you will learn how to create and populate a Notes database with application activity information.
 
 
Content
Please note that these Notes/Domino tutorials are no longer being updated, and are presented here as an archive of information.

Logging Application Activity


Back to Main Menu

Introduction
Introduction to Logging Application Activity

Creating an Application Activity Log
Creating an Application Activity Log Database

Logging Information to a Database
Creating a NotesLog Object
Opening a NotesLog Object
Logging Actions
Logging Errors

Exercise
Logging Application Activity
Exercise Solution


Introduction



Introduction to Logging Application Activity

A NotesLog object can be used to record actions and errors that occur in scripts. This information can be stored in one of the following ways:
  • Notes database
  • Mail memo
  • Text file (local scripts only)

    In this Learning Byte, you will learn how to create and populate a Notes database with application activity information.


    Creating an Application Activity Log



    Creating an Application Activity Log Database

    To log script activity in a Notes database with the NotesLog object, do the following:

    1. Create a Notes log database from the ALOG4.NTF template.
    2. Create a new NotesLog object in the script of the application whose activity you want to record.
    3. Open the Log database.
    4. Record specific activities or errors.


    Logging Information to a Database



    Creating a NotesLog Object

    Once you have created the database you will use for logging, the next step in logging application activity is to create the NotesLog object. This procedure is similar to creating other LotusScript objects.

    Syntax

    Dim variableName as New NotesLog(scriptName$)
    or
    Set myLog = New NotesLog(scriptName$)

    In this example, scriptName$ identifies the script whose actions and errors you want to log. It is used in the application activity log database to categorize the log entries. You should specify a unique name for each script in your application, so you can easily identify which script recorded which entry.

    Example

    Assume you have scripts attached to a query button and an update button.
    Behind the query button, you might set up a NotesLog object as follows:
    Dim myLog as New NotesLog("Query")

    Behind the update button, you might set it up like this:
    Dim myLog as New NotesLog("Update")


    Opening a NotesLog Object

    The application activity log database must be opened before a script's activity can be logged. To open the database, use the following method:

    Call MyLog.OpenNotesLog(server$, dbfile$)

    When writing to a database, a new document is created for each action or error that is logged. Each document contains the following information:
  • The ProgramName property
  • The date and time the error or action was logged
  • The user of the script at the time the error or action was logged
  • The type of entry ("Error" or "Action")
  • A description of the action (Actions only)
  • The error code (Errors only)
  • A description of the error (Errors only)

    A script must have at least Reader access in order to open a database.
    If a script runs on a server, it cannot open a database on another server. An error will be generated if this is attempted.

    Logging Actions
    You must explicitly direct a script to log an action in the NotesLog. Notes does not automatically record this information.

    Use the LogAction method to log an action.

    Syntax

    Call notesLog.LogAction(description$)

    In this example, description$ is a description of the action the script performed as you want it to appear in the log.

    Example

    Call myLog.LogAction("Processed document" + Cstr(count%))


    Logging Errors
    Use the LogAction method to log script errors.

    Syntax

    Call notesLog.LogError(code%, description$)

    In this example, code% is an integer indicating the error that has occurred. The
    description$ string describes the error as you want it to appear in the log.

    Example

    Call myLog.LogError(IsERR_NOTES_DATABASE_NOTOPEN,"Unable to open " & db.FileName)


    Exercise



    Logging Application Activity


    Introduction

    In this exercise, you will set up a simple application activity log database. The Logging App Activity - Exercises database, Laaex.nsf, contains a form with a button that tries to open a view that does not exist.

    Instructions

    1. Download this database to your notes/data directory and add it to your workspace.
    Logging App Activity - Exercises (Laaex.nsf attached below).

    2. Create an application activity log database based on the Agent Log template (ALOG4.NTF). Enter "agentlog.nsf" for the filename.

    3. Open the Logging - Exercise form in the Logging App Activity - Exercises (Laaex.nsf) database.

    4. In the Click event of the button, write a script that searches for the given view name.
    • If the view is not found, log an error stating so.
    • If the view is found, log a message stating that is was found successfully.
5. Choose Create -> Logging - Exercise and click the button. Examine the log entry created in agentlog.nsf.

6. Go back to the button's script and change the value of viewname to the name of the view that already exists. Test the LogAction method by repeating Step 5.

Exercise Solution

Sub Click(Source As Button)
viewName$ = "Wrong Viewname"
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim currentLog As New NotesLog("Logging Demo")
Call currentLog.OpenNotesLog("","agentlog.nsf")
Set db = session.currentdatabase
Set view = db.GetView(viewName$)
If view Is Nothing Then
Call currentLog.LogError(0,"Unable to locate view: " + viewName$)
Else
Call currentLog.LogAction("Successfully located view: " + viewName$)
End If
Call currentLog.Close
End Sub
 
Laaex.nsf
 
 

Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
Rate this page
Please take a moment to complete this form to help us better serve you.
This material provides me with the information I need.




This material is clear and easy to understand.




Did the information help you to achieve your goal?
What updates, improvements, or related information would you like to see in this document?
Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.
Input the verification number to submit feedback:
Document information
 Product categories:
 Software
 Messaging Applications
 Advanced Messaging
 Lotus Domino
 Lotus Domino Server
 Operating system(s):
  AIX, Linux, Solaris, Windows, i5/OS
 Software version:
  4.5, 4.6, 5.0, 6.0, 6.5
 Reference #:
  7006085
 IBM Group:
 Software Group
 Modified date:
 2007-03-19

Translate My Page
 
 

Rate this page

Help us improve this page. Your response will be used to improve our document content. Requests for assistance, if applicable, should be submitted through your normal support channel as we cannot respond from this site.