This article explains how to redirect STDOUT and STDERR to the same LOG file when executing an application.
Problem:
How do you redirect STDOUT and STDERR to the same LOG file when executing an application?
In this sample program, it writes on the STDOUT the display statements and it generates an error because of a not found program. What can be done to avoid this?
PROCEDURE DIVISION.
perform 2 times display "To Stdout" end-perform *> msg to STDOUT
call "DOERROR" *> msg to STDERR
Resolution:
To redirect STDOUT and STDERR to the same LOG file, use the following:
On UNIX:
cobrun programname >ABC.log 2>>ABC.log
OR
programname >ABC.log 2>>ABC.log if linked program
On Windows:
set COBSW= S
run programname >ABC.log 2>>&1
OR
programname >ABC.log 2>>&1 if linked program
Runtime Switch S5 Use redirectable console I/O