Custom Task Guide

Custom Task Guide

Implement Logging

Implement Logging

Every execution of a
Managed File Transfer
Project produces a job log that contains important events. Most of the events come from the tasks within the project. The task author makes appropriate decisions on what should be logged depending on the log level that the task is running under. Logging is done by firing log events. A log listener is registered with every task in the project. The log listener takes on the responsibility of logging the messages to the job log file. Listed below is the code snippet with some log messages from the execute() method:
Please note that the red text denotes the new source added to the example.
public void execute() throws ExecutionException { if (isNormalLogLevel()) { fireInfo(this, "Copy Task started"); } internalValidate(); try { if (isVerboseLogLevel()) { fireInfo(this, "Copying file " + sourceFile + " t directory " + destinationDirectory); } long bytesCopied = copy(); if (isVerboseLogLevel()) { fireInfo(this, bytesCopied + " byte(s) copied"); } } catch (IOException exp) { throw new ExecutionException(exp.getMessage(), exp); } if (isNormalLogLevel()) { fireInfo(this, "Copy Task finished"); } }

0 COMMENTS

We’d like to hear from you!