Strovent SystemsSign in
Reference

IBM i job log missing or empty: CHGJOB LOG, LOGCLPGM and pending job logs

A job that ends normally often leaves no QPJOBLOG because of LOG(4 0 *NOLIST), or its log sits pending. Use WRKJOBLOG, change LOG to *SECLVL and set LOGCLPGM.

A batch job ended and you want its job log, but there is no QPJOBLOG spooled file, or the job log has only a few lines. Three job attributes decide this: what gets logged, whether a log is kept when the job ends well, and who writes it out.

No job log after a normal end

The LOG attribute has three parts: level (0 to 4), severity (0 to 99) and text. The text part can be:

  • *MSG: message text only.
  • *SECLVL: message text and the message help (cause and recovery).
  • *NOLIST: no job log if the job ends normally. A job log is still written if it ends abnormally, with an end code of 20 or higher.

The default for a new job description is LOG(4 0 *NOLIST), so jobs that use such a job description leave nothing behind when they end normally. To keep the log, submit the job with another value:

SBMJOB CMD(CALL PGM(MYLIB/MYPGM)) JOB(MYJOB) LOG(4 00 *SECLVL)

or change the job description with CHGJOBD ... LOG(4 00 *SECLVL). For a job that is already running, CHGJOB JOB(123456/USER1/MYJOB) LOG(4 00 *SECLVL) changes it from then on.

The job log is too short

  • Commands inside a CL program are missing. Set LOGCLPGM(*YES) on CHGJOB, SBMJOB or the job description. It works for CL programs compiled with LOG(*JOB), the default; a program compiled with LOG(*NO) is never logged. Logging level 3 or 4 is also needed.
  • Messages are missing. A lower level or a higher severity drops messages. Level 4 with severity 0 keeps everything.

The job log is pending

LOGOUTPUT decides who writes the job log when the job ends:

  • *JOBEND: the job writes its own log.
  • *JOBLOGSVR: a job log server writes it.
  • *PND: nothing is written, and the log stays pending until it is removed.

Jobs take the value from their job description, which by default points to the QLOGOUTPUT system value. A pending job log is not a spooled file, so it does not show in WRKSPLF. To find and open it:

WRKJOBLOG JOBLOGSTT(*PENDING)
DSPJOBLOG JOB(123456/USER1/MYJOB)

Other ways to read a job log

  • Your own interactive job: DSPJOBLOG, then F10 for detailed messages. Or sign off with SIGNOFF LOG(*LIST) to keep it.
  • An ended job whose log was written: WRKSPLF or DSPSPLF FILE(QPJOBLOG) JOB(123456/USER1/MYJOB).
  • With SQL: SELECT * FROM TABLE(QSYS2.JOBLOG_INFO('123456/USER1/MYJOB')).

To see another user's job log you need *JOBCTL special authority.

Sources

Spotted a mistake? Email [email protected].