How to Write to the Process Log using Groovy

Document created by Adam Arrowsmith Employee on Feb 15, 2012Last modified by chris_stevens on Jul 14, 2016
Version 3Show Document
  • View in full screen mode

When using scripting within a Map Function or Data Process step, it can be very helpful to view to values of variables at run time to assist with development and debugging. You can do this by writing entries to the Process Log using Groovy script.

 

Notes:

  • This can only be done with Groovy scripting. Javascript will not work.
  • This will write entries to the Process-level Log. You cannot write to the Document-level Log.
  • Alert notifications will NOT be sent for entries, regardless of Log Level (e.g. Warning or Errors).

 

Use the following syntax in your Groovy scripts:

At the top of scripting, include an import statement for the ExecutionUtil and Logger class and get a handle to the Logger class. For those familiar with Java, this is the standard Java Logger class.

import com.boomi.execution.ExecutionUtil;
import java.util.logging.Logger;

Logger logger = ExecutionUtil.getBaseLogger();

 

Then throughout your script, use the following line to write an entry to the Process Log.

logger.info("Hello Process Log!");

 

One of the main purposes of writing to the Process Log is to inspect the value of a variable at run time, so you can reference that variable in the log entry. Simply include the variable in the message string like this.

logger.info("Processing customer: " + customerNumber);

 

Additional methods that can be used are:

fine(String message),

finer(String message),

finest(String message),

warning(String message),

severe(String message)

to create entries with different Log Levels.

 

Tip: Create your messages at the WARNING level to be able to quickly filter the Process Log to find your entries. Remember, even though it is a WARNING level, it will not generate an alert notification or affect the document or execution status.

 

Additional information can be found at the following Oracle JAVA API link: Logger (Java Platform SE 6)

5 people found this helpful

Attachments

    Outcomes