Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Open Agent Log using LotusScript

I have run a specific agent in the following code:

Set theAgent = db.GetAgent(Cstr(agent.Name))
Call theAgent.Run

At the same time, I want to open the Agent Log after the Agent run. But, it cannot open the Agent Log and error message cannot occur. How can I do that?

0
KenyonKen
Asked:
KenyonKen
  • 3
  • 3
1 Solution
 
scottrmaCommented:
In your agent, you need to create a NotesLog class object and then log to it as follows:

Syntax
Dim variableName As New NotesLog(programName$)
or
Set notesLog = New NotesLog(programName$)

Parameter
programName$
String. A name that identifies the log.

Usage
Once you create a log using New, use the OpenAgentLog method to open the log before writing to it. You must explicitly log each action and error using the following methods:
To log an action, use LogAction.
To log an error, use LogError.
Notes does not automatically log actions or errors for you.

Regards,

Scott
0
 
KenyonKenAuthor Commented:
Thanks....Scott

I can implement the Agent Log now, but I need to do more is that I want to open the Agent Log just like when I test the Agent in Notes Designer. The report pop up after the agent run. Can I do this?

Cheers,
Kenyon
0
 
scottrmaCommented:
I don't think you can do this. I checked all the methods and properties in the NotesLog and NotesAgent class, and I don't see where you can do this. The little dialog window you are talking about only seems to come up when the agent is invoked from Domino Designer. You can use the following code to write to the agent log:

     Dim agentLog As New NotesLog("Agent log")
     Call agentLog.OpenAgentLog
     Call agentLog.LogAction("Action one")
     Call agentLog.Close

but there is no code available to make the little window pop up if the agent was not called to run from within Domino Designer, nor is there any code to programmatically read from the agent log, only to write to it.

Sorry, I have checked everywhere, so unless I am missing something (other experts will tell you immediately if this is the case), I don't think you can do what you are asking.

Regards,

Scott
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
KenyonKenAuthor Commented:
Hi Scott,

I also find all the meothods to provide that agent log, but still not find. So, I can only use :

"Call currentLog.OpenFileLog( "c:\log.txt" )"

to output the agent log instead. Do you have any more suggestions?

Cheers,
From Kenyon
0
 
scottrmaCommented:
Well, yes, if you use OpenFileLog, then you will have the logging contents as a file on disk, and you could subsequently access that file, either manually or programmatically.

The only other way would be to code the logging mechanism yourself. That would basically involve creating a database with a form and fields and views to hold your log data and then in your agent you simply create log documents in this database. The Agent Log you are referring to doesn't really give out that much information anyway, just things like agent start time, number of documents the agent found to run on, agent end time. So it would be fairly easy to code this yourself. Example: use the Now() function at the beginning and end of your script to get the agent start and end times, and use session.CurrentDatabase.UnprocessedDocuments.Count property to get the number of documents the agent found to run on. Then just write this info to your custom log database.

Regards,

Scott
0
 
KenyonKenAuthor Commented:
Thanks o lot, Scoot.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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