Logging within scripts

In order to trace and track Flex script action execution it can be useful to add logging statements. The is done via the provided context object:

 def execute() {
   context.logInfo("This is an information message") 
   context.logWarn("Indicates that something unexpected occurred, but one that is not fatal") 
   context.logError("Indicates that an unrecoverable error has occured") 
 }

In previous versions of Flex, calling the logging methods on context would raise an event for the job object, visible on the history tab within the Enterprise UI. Logging statements from within scripts now output to the standard Flex logging infrastructure, visible via Kibana, with only warnings and errors raising job events as well.

For example, assuming we had the following script action, running as job 349719:

def execute() {
  context.logInfo("This is a log statement") 
}

Executing a job of this action means that we can query Kibana using the KQL jobId:349719:

Placeholders

When creating log messages you can use placeholders to keep the messages easy to read:

content.logInfo("The asset ID is {}", asset.id)
content.loError("{} assets returned when expecting {}", assets.size, expectedSize)