Viewing Java batch job logs
When you are running Java batch jobs in the WebSphere Application Server Liberty, a log is written for each job.
The logs are created in the following directory structure:
For more information about retrieving or deleting job logs by using the REST API, see the REST API administration documentation.
Configuring job logging
Batch job logging can be configured by using the <batchJobLogging>
<batchJobLogging enabled="true" maxRecords="1000" />.
maxRecords indicates the number of records that are written to a
job log part before the records roll over to the next part.
The batch feature uses a logger that is named com.ibm.ws.batch.JobLogger to log
certain batch messages to the job log only. Examples include job lifecycle messages and checkpoint
messages. The logger does not write to the server log. By default, the logger is enabled for
Level.FINE messages. You can configure the level of the logger by specifying it in
the trace specification of the server. For example,
Any log messages that are written by the job thread, including messages that are written by the run time and by application code, are written to both the job log and the server log.
The System.out and System.err files are only written to the server log and are not written to the job log.
Partitioned steps have more subdirectories for each partition. The log files in the execution ID directory contain entries from the thread that is running the top-level job. The job logs for the partitions are stored with the following structure:
ID/execution.execution ID/name of partitioned
If a split flow occurs in the job, more subdirectories are created to capture the output from the thread of each flow. The log files that are located directly under the execution ID directory contains entries from the thread that is running the top-level job. The job logs for individual flow threads are stored with the following structure:
ID/execution.execution ID/split ID/flow
Job log events
If batch job events are enabled, then job log events are published when a job log part is
completed and when a job goes to an ended state, such as
completed. The job log event messages contain multiple
JSON properties to help with identifying the message along with the actual job log file content.
//The retrieved job log event message Message msg //Convert the Message to a TextMessage TextMessage txtMsg = (TextMessage) msg; //Convert the text in the message to a JsonObject JsonObject jobLogEventObject = Json.createReader(new StringReader(txtMsg.getText())).readObject(); //Pull the job log text content from the JsonObject as an example JsonArray logContentArray = jobLogEventObject.getJsonArray("contents");
For more information about enabling batch job events, see Enabling batch job events publishing.