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)onCHGJOB,SBMJOBor the job description. It works for CL programs compiled withLOG(*JOB), the default; a program compiled withLOG(*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, thenF10for detailed messages. Or sign off withSIGNOFF LOG(*LIST)to keep it. - An ended job whose log was written:
WRKSPLForDSPSPLF 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.
Related
- IBM i job in MSGW status: find the message and reply to it
- End a stuck IBM i job: ENDJOB CNTRLD, IMMED and ENDJOBABN
- Automate IBM i green-screen tasks: job scheduler, SBMJOB, SSH and screen scripts
- IBM i CL basics
- The IBM i System Request menu
Sources
- IBM i 7.5: How job logs are created
- IBM i 7.5: Displaying a job log
- IBM i 7.5: Change Job (CHGJOB), LOG, LOGCLPGM and LOGOUTPUT
- IBM i 7.5: Create Job Description (CRTJOBD), default LOG values
- IBM i 7.5: Logging CL program or procedure commands
- IBM i 7.5: Display Job Log (DSPJOBLOG)
- IBM i 7.5: JOBLOG_INFO table function