Sandesh Bhat
Sandesh Bhat

Reputation: 13

Lotus Notes : Can Msgbox print in text file same as log.nsf

Hi all i have a doubt regarding message box which writes logs in log.nsf in my application msgbox is printing the logs while generating but i have created a file in the path E:\logs\a.txt (manually). and i have to record the Msgbox messages in that a.txt file so kindly can anyone tell how to modify the message box such that it will write to the txt file as well.

now i am using this code to print the logs in log.nsf

Messagebox "Error id not found"

and some where

Msgbox "Error id not found"

Kindly help how to edit this code and print it in the text file.

Upvotes: 0

Views: 1202

Answers (2)

D.Bugger
D.Bugger

Reputation: 2359

Why not use the NotesLog class? It's there for all logging purposes (file, agent log, mail..)

As suggested (thanks!), a simple example, straight from the Help database:

Sub Initialize
  Dim currentLog As New NotesLog( "Checkup Agent" )
  Call currentLog.OpenMailLog( "Jimmy Ho", "Log for Checkup Agent" )
  Call currentLog.Close
End Sub

When the log is closed, a mail will be sent to Jimmy Ho.

There are other ways to set up a log: to a file, to the agent, to mail, and to a Notes database. I usually use OpenNotesLog, so I can log in a Notes database. That database should have been created using the AgentLog template.

To a file:

In Declarations:
  Dim currentLog As NotesLog

Sub Initialize
  Set currentLog As New NotesLog( "My File Log" )
  Call currentLog.OpenFileLog( "d:\logfile.txt" )
End Sub

and elsewhere in your code:

  Call currentLog.LogError (1001, "Id not found")

The log will be closed automatically.

Check also what the OpenLog project from OpenNTF.org can do for you.

Upvotes: 2

Michael Ruhnau
Michael Ruhnau

Reputation: 1399

You can't achieve this using MessageBox. You can use the Print # statement (LotusScript Language) to write data to a text file though. This example will write a log file on your local disc:

Dim fileNum As Integer
fileNum% = Freefile()
Open "d:\logfile.txt" For Output As fileNum%
Print #fileNum%, "Error id not found"
Close fileNum%

Upvotes: 1

Related Questions