A comparison of standard and intentional logging

The following two Gosu examples illustrate the differences between Guidewire standard logging and Guidewire intentional logging. The purpose of each example is to log a file processing event.

Standard logging example

uses gw.api.system.PCLoggerCategory

var  logger = PCLoggerCategory.INBOUND_FILE

try {

  var fName = "file_for_processing"  //Retrieve file name
  logger.info( "Starting inbound file " + fName +  " processing {}")
  // Business logic
  logger.info( "Finished inbound file processing {}")

} catch (SomeException) {
  logger.error( "Some exception happened")
} 

Intentional logging example

uses org.slf4j.MarkerFactory
uses gw.pl.logging.LogMessageParams
uses gw.api.system.PCLoggerCategory
uses gw.api.intentionallogging.IntentionalLogger

var fName = "file_for_processing"  //Retrieve file name here
var IL = IntentionalLogger.from(PCLoggerCategory.INBOUND_FILE)
var INBOUND_FILE_PROCESSING = MarkerFactory.getMarker("InboundFileProcessing")

try {

  IL.logStart( INBOUND_FILE_PROCESSING, " : ", LogMessageParams.create().put("file_name", fName))
  // Business logic
  IL.logStop( INBOUND_FILE_PROCESSING, " : ", LogMessageParams.create().put("file_name", fName))

} catch (ParseException) {
  IL.logError(INBOUND_FILE_PROCESSING, "Error")
}