Logging CL program or procedure commands

You can specify that most CL commands that are run in a CL program or procedure be written (logged) to the job log.

To log CL commands, specify one of the following values on the LOG parameter on the Create Control Language Module (CRTCLMOD) command or the Create Bound Control Language Program (CRTBNDCL) command when the CL source program is compiled:

*JOB
This default value indicates that logging is to occur when the job's logging option is on. The option is initially set for no logging, but it can be changed by the LOGCLPGM parameter on the Change Job (CHGJOB) command. Therefore, if you create the module or program with this value, you can alter the logging option for each job or several times within a job.
*YES
This value indicates that logging is to occur each time the CL program or procedure is run. It cannot be changed by the CHGJOB command.
*NO
This value indicates that no logging is to occur. It cannot be changed by the CHGJOB command.

Because these values are part of the Create Control Language Module (CRTCLMOD) and the Create Bound Control Language Program (CRTBNDCL) commands, you must recompile the module or program to change them.

When you specify logging, you should use the Remove Message (RMVMSG) command with care in order not to remove any logged commands from the job log. If you specify CLEAR(*ALL) on the RMVMSG command, any commands logged before running the RMVMSG command do not appear in the job log. This affects only the CL program or procedure containing the RMVMSG command and does not affect any logged commands for the preceding or following recursion levels.

Not all commands are logged to the job log. The following list is about commands that are not logged.

CALLPRC CALLSUBR CHGVAR
DCL DCLF DCLPRCOPT
DO DOFOR DOUNTIL
DOWHILE ELSE ENDDO
ENDPGM ENDSELECT ENDSUBR
GOTO IF INCLUDE
ITERATE LEAVE MONMSG
OTHERWISE PGM RTNSUBR
SELECT SUBR WHEN

If the logging option is on, logging messages are sent to the message queue of the CL program or procedure. If the CL program or procedure is running interactively, and the message level on the job's LOG parameter is set to 4, you can press F10 (Display detail messages) to view the logging of all commands. You can print the log if the message level is 4 and you specify *PRINT when you sign off.

The log includes the time, program and procedure names, message texts, and command names. Command names are qualified as they are on the original source statement. Command parameters are also logged; if the parameter information is a CL variable, the contents of the variable are printed (except for the RTNVAL parameter).

Logging of commands affects performance.