System log

Log an error to the standard logger. This is the recommended way to add output to your log files.

Folder Monitor and ERROR

Logging something as an ERROR in a Folder Monitor script will cause the current file to be thrown in the error folder (in other words, 360 considers ERROR logging as a failure and will treat it the same way as if an exception is thrown from the script).

Usage

There are five different logging levels:

  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • FATAL

Guidelines for each level

DEBUG

Use debugging for any message that is technical in nature and doesn't say anything important about the overall execution of your script. Examples such as:

BCCLog.getLogger().debug("File already exists in folder, no need to process new file.", null);
BCCLog.getLogger().debug("Record does not exist in database table", null);
BCCLog.getLogger().debug("Found 15344 files in folder", null);

As a rule of thumb, when you set your services to show logging of INFO and above (in other words not DEBUG logging) you should not get a log cluttered with details of what the script is doing.

INFO

Information logging is good to use to display what your script is doing on a larger level. A common scenario for a script might be to 1) Get data 2) Process data 3) Backup old data 4) Save data 5) Notify user. Each of these steps can be considered a good candidate for INFO logging, like:

BCCLog.getLogger().info("Getting data from AS400", null);
BCCLog.getLogger().info("Creating order objects and processing order lines", null);
BCCLog.getLogger().info("Backup of current data", null);
BCCLog.getLogger().info("Saving new order info", null);
BCCLog.getLogger().info("Sending email to application owner", null);

WARNING

This level should be used to indicate something that was unexpected but could be handled, such as when the description of an order is empty. While this should not cause an error it is suspicious that the description was missing. A good rule of thumb is to include some explaining message to the administrator/or whomever is looking at the log files, like:

BCCLog.getLogger().warn("The order date was over a year ago. Please contact the division owner and ask them to verify that this order is correct.", null);

For many cases you might also want to include addition notifications when logging warnings, like sending an email or automatically creating a bug/issue.

ERROR

When something is not working as intended you should log an error (for ERROR in a Folder Monitor job, see above). Errors will almost always need attention from someone so make sure to include a good description on what is wrong, where to look for data that was used by the script, any configurations, and include any instance variables that might be of value for the person trying to fix the error (such as the parameters used in an SQL query, or values read from an XML file, dates used, etc). In short, there can never be too much information included in an error message, just make sure you display it nicely.

BCCLog.getLogger().error("Error processing order with ID = " + orderid + ", with date = " + date + ", with filepath = " + filepath + ", using param1 = " + param1 + ", param2 = " + param2 + ", param3 = " + param3, null);

Usually you will quickly save the time writing the error message when any errors happen in production code.

FATAL

This logging level should be used when the script cannot continue process and needs to quit immediately.

BCCLog.getLogger().fatal("Abnormal message payload", null);