Re: writing to a log reliably



Mark,
There's no difference in the code below for Replace and Append! Surely a typo?

Les (Change Arabic to Roman to email me)



markh wrote:
On Jun 17, 8:59 am, AJ <ajNOwebSPAMo...@xxxxxxxxxx> wrote:
Hi,
I'm sure everyone must have a version of this ...

But how do I write to a log file reliably?

I have a simple procedure to append a line of text to a log file then
close the file. This works fine on my Linux test machine, but when I run
it on the main AIX server I find that only the first call to my log
procedure seems to produce anything.
The rest of the program works fine and any SAY statements I put in the
procedure display correctly, but nothing new is added to my log.

Any ideas?

This is using oorex 3.2 with classic code only.

Here's the test program
*Rexx */
Trace 'o'
/* log testing */
log_name='/home/alan/logtest.log'
call logit "Start of run"
Do k = 1 to 10
Call logit "Inside loop ==> " k
end
Exit

logit: procedure expose log_name
parse arg logline
logline2 = time("c") logline
rc = Lineout(log_name,logline2)
rc = Lineout(log_name)
say logline2
return

On linux I get 11 lines output to the log.
On AIX I just get the first line "Start of run"

That looks like a bug with ooRexx on AIX. I'd suggest you log a bug
report on the ooRexx SourceForge site:
https://sourceforge.net/tracker/?group_id=119701&atid=684730

To be more reliable anyway, you should specify how you want the log
file opened. Do you want to overwrite the contents of the existing
log file (if any), or append to it.

Before you write to the file, explicitly open it. And when you have
finished writing, close it.

To replace:

Call Stream log_name, 'C', 'OPEN WRITE REPLACE'

To append:

Call Stream log_name, 'C', 'OPEN WRITE REPLACE'

To close:

Call Stream log_name, 'C', 'CLOSE'

Cheers, Mark
.



Relevant Pages

  • Re: writing to a log reliably
    ... But how do I write to a log file reliably? ... logline2 = timelogline ... On AIX I just get the first line "Start of run" ... Call Stream log_name, 'C', 'OPEN WRITE REPLACE' ...
    (comp.lang.rexx)
  • Re: [fw-wiz] More Syslog Questions
    ... > The only problem I have with chattr +a is that if an intruder gains ... > and the replace the append only attribute, ... > done to the log file. ...
    (Firewall-Wizards)
  • Re: Trimming the appended FileStream
    ... Just open a file in OpenOrCreate mode and then use FileStream.Seekto append new text to the end of log file. ... {private const string LOGGER = "LOGGER> "; ... if (consoleOutput) Console.WriteLine; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: writing to a log reliably
    ... But how do I write to a log file reliably? ... logit: procedure expose log_name ... logline2 = timelogline ... proc3: procedure ...
    (comp.lang.rexx)
  • writing to a log reliably
    ... But how do I write to a log file reliably? ... Here's the test program ... logit: procedure expose log_name ... logline2 = timelogline ...
    (comp.lang.rexx)

Loading