 |
 |
| Domino Tips: |
|
 |
 |

AGENT
NotesLog class sample code from Maximizing Agent Performance webcast
Dave Hatter and Tim Bankes 05.19.2003
Rating: -3.17- (out of 5)




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


');
// -->
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.
|
 |
|
|
 |
|
 |
 |
 |
 |
| 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 . |
|
| |
All Rights Reserved, , TechTarget |
|
|
|
|
|