There are two basic commands for viewing messages, Display Message, DSPMSG, and Work with Messages, WRKMSG. The two commands are virtually identical.
Type the Display Message command, DSPMSG, on the command line and press Enter to display messages. By default, the DSPMSG command displays the messages for your user profile’s message queue and the display station’s message queue. To view just the messages for our user profile, we can run the command DSPMSG MSGQ(*USRPRF). To view the messages for just the display station, we can enter the command DSPMSG MSGQ(*WRKSTN).
Messages typically have two levels of detail. Level one, the simplest, is what is listed when we enter the DSPMSG or WRKMSG commands. To get to level two, which provides a greater level of detail, set the cursor on the message text and press F1. The second level message will then be displayed. From the second level message, pressing F9 will give us even greater detail.
The command panel for the DSPMSG command has three function keys that will remove messages from the queue. We should be careful when using these function keys. If we move the cursor to a message and press F11, the system will then remove the message from the queue. F13 will remove all messages, including inquiry messages that have not been answered yet. F16 removes all messages, excluding inquiry messages that have yet to be answered.
The QSYSOPR system operator has its own message queue that is also named QSYSOPR. Error and informational messages about jobs that are running and require some sort of special intervention are sent to the QSYSOPR message queue. The QBATCH subsystem usually sends all system operator messages to the QSYSOPR message queue.
The QSYSOPR message queue is especially helpful in troubleshooting problems and confirming that system events actually occurred. We can display the messages in the QSYSOPR message queue using the Display Message command, DSPMSG. We supply QSYSOPR as the name of the message queue, so that the full command is DSPMSG MSGQ(QSYSOPR).
By default, the most recent messages are displayed first. If we want to start with the oldest messages, we can use the START parameter and specify *FIRST; this will display the messages in order from first received to last received. The default for the START parameter is *LAST, where the messages are displayed in order from last received to first received; this ordering ensures that we see the latest messages first. For example, issuing the command DSPMSG MSGQ(QSYSOPR) START(*FIRST) should list messages relating to the system IPL.
Messages are collected into logs, such as the job log. Each user in an interactive session has a job log that aggregates the messages and the commands that they run. We can quickly access the job log by issuing the DSPJOBLOG command. To view complete information for the messages in the job log, position the cursor over the desired message and press F1.
The IBM i also has a system-wide log called QHST.The QHST log provides us with a record of system activity. We can view the system log by executing the Display Log command, DSPLOG. The system log is a message queue object, *MSGQ. Note that the QHST system log has a fixed size. When the QHST system log is full, the system copies QHST in a database file and then clears it of all contents.
The QHSTLOGSIZ system value indicates the maximum number of records that can be kept in the history log. We can view this value by issuing the command DSPSYSVAL SYSVAL(QHSTLOGSIZ). We can specify a number or else *DAILY when modifying this value; the default is 5000. Please be aware that changes to this system value take effect only after a new history log is created.