Home > Domino Tips > Developer > Agent > NotesLog class sample code from Maximizing Agent Performance webcast
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

AGENT

NotesLog class sample code from Maximizing Agent Performance webcast


Dave Hatter and Tim Bankes
05.19.2003
Rating: -3.17- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


As promised this is the NotesLog class sample code so many of you wanted from the webcast
"Maximizing Agent Performance" with Dave Hatter and Tim Bankes.
The following sample code is presented in LotusScript and Java.

Code

LOTUSSCRIPT

Sub Initialize 
        ' Last mods 0304014 - 
Dave Hatter - dhatter@libertastechnologies.com
 - www.libertastechnologies.com 
        ' This code will write log messages
 to a text file. 
        On Error Goto Errhandler 
        Dim nsCurrent As NotesSession 
        Dim nlogCurrent As NotesLog 
        Set nsCurrent = New NotesSession 
        Dim strMsg As String, strNL As String 
        Set nLogCurrent =nsCurrent.CreateLog
( nsCurrent.CurrentAgent.Name ) 
        Call nlogCurrent.OpenFileLog
("c:davetestLS.txt") ' This will write to the
 local drive, insert a valid path for your 
environment here 
      ' **** Enable/Disable logging here 
        nLogCurrent.LogErrors=True 
        nLogCurrent.LogActions=True 
        nLogCurrent.LogAction("*** Starting ***") 
        strNL=Chr(10) & Chr(13) 
        With nsCurrent 
                strMsg="Notes Version:" & 
.NotesVersion &  " " & .NotesBuildVersion 
                nLogCurrent.LogAction
("Notes Version:" & .NotesVersion &  " " 
& .NotesBuildVersion) 
                strMsg=strMsg & strNL & 
"Platform:" & .Platform 
                nLogCurrent.LogAction
("Platform:" & .Platform) 
                strMsg=strMsg & strNL & 
"User Name:" & .UserName 
                nLogCurrent.LogAction
("User Name:" & .UserName) 
                strMsg=strMsg & strNL & 
"Database Name:" & nsCurrent.
CurrentDatabase.Title 
                nLogCurrent.LogAction
("Database Name:" & nsCurrent.
CurrentDatabase.Title) 
                strMsg=strMsg & strNL &
 "Database File:" & nsCurrent.
CurrentDatabase.FilePath 
                nLogCurrent.LogAction(
"Database File:" & nsCurrent.
CurrentDatabase.FilePath) 
                strMsg=strMsg & strNL & 
"Agent Name:" & nsCurrent.
CurrentAgent.Name 
                nLogCurrent.LogAction
("Agent Name:" & nsCurrent.
CurrentAgent.Name) 
                Msgbox strMsg,64,
"Notes Information" 
        End With 
        nLogCurrent.LogAction
("*** Ending ***") 
        nLogCurrent.Close 
        Exit Sub 
Errhandler: 
        Call nlogCurrent.LogError
(Err,"An Error:" & Error$ & "( " & 
Cstr(Err) & ") has occured on line "
 & Cstr(Erl)) 
        nlogCurrent.LogAction
("*** Abending ***") 
        nlogCurrent.Close 
        Exit Sub 
End Sub 

JAVA

 
import lotus.domino.*; 
// Last mods 0304014 - Dave Hatter - 
dhatter@libertastechnologies.com - 
www.libertastechnologies.com 
// This code will write log messages 
to a text file. 
public class JavaAgent extends
 AgentBase { 
        public void NotesMain() { 
                try { 
                        Session nsCurrent = 
getSession(); 
                        AgentContext nacCurrent 
= nsCurrent.getAgentContext(); 
                        Log nlogCurrent = 
nsCurrent.createLog(nacCurrent.
getCurrentAgent().getName()); 
                        nlogCurrent.openFileLog
("c:davetestJava.txt"); //' This will write to
 the local drive, insert a valid path for 
your environment here 
nlogCurrent.logAction("*** Starting ***"); 
System.out.println("Notes Version:" 
+ nsCurrent.getNotesVersion());                                         
nlogCurrent.logAction
("Notes Version:" + nsCurrent.
getNotesVersion()); 
System.out.println("Platform:" + 
nsCurrent.getPlatform()); 
nlogCurrent.logAction("Platform:" + 
nsCurrent.getPlatform()); 
System.out.println("User Name:" + 
nsCurrent.getUserName()); 
nlogCurrent.logAction("User Name:" + 
nsCurrent.getUserName()); 
System.out.println("Database Name:"
 + nacCurrent.getCurrentDatabase
().getTitle()); 
nlogCurrent.logAction("Database 
Name:" + nacCurrent.getCurrentDatabase()
.getTitle()); 
System.out.println("Database File:" 
+ nacCurrent.getCurrentDatabase().
getFilePath()); 
nlogCurrent.logAction("Database File:" 
+ nacCurrent.getCurrentDatabase().
getFilePath()); 
System.out.println("Agent Name:" +
nacCurrent.getCurrentAgent().getName()); 
nlogCurrent.logAction("Agent Name:" + 
nacCurrent.getCurrentAgent().getName()); 
nlogCurrent.logAction("*** Ending ***"); 
nlogCurrent.close(); 
  } catch(Exception e) { 
 e.printStackTrace(); 
                } 
        } 
} 

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Agent
Run or restart Notes/Domino agents via text messages
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design
Creating custom views in Lotus Notes databases
Editing fields in a Lotus Notes view with Ajax

LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication

Java for Lotus Notes Domino
Top 10 Lotus Notes/Domino coding and development tips of 2008
Java code inserts data from Notes documents into a SQL table
Java code shortens strings in a SQL table
How to execute a stored procedure in Lotus Notes Domino using Java
Top 10 Lotus Notes Domino programming and development tips of 2007
How to return an HTML representation of a Lotus Notes rich-text field
Shrink Lotus Notes databases with many attachments
Converting Lotus Notes Domino Web pages to PDF files with a Java agent
Developing Eclipse plug-ins for Lotus Notes and Domino -- 7 tips in 7 minutes
A bevy of Notes/Domino development tips

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts