Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor


As discussed in my previous blog, HCI - Payload Logging using Groovy Scripts logging of payloads should be used prudently. Typically you would like the logging to be disabled and have options to enable this only on a need basis.

If you are from a PI background, you would be well aware of parameters like TRACE_LEVEL, LOGGING_SYNC and Integrated Configuration Logging Options that enable you to turn on / off logging & staging when required. So how can this be done in HCI using the Groovy scripts we described in the previous blogs?

Externalized Parameters in HCI

Some background first - HCI enables you to define parameters that can be controlled externally in your Integration Flow. Typical examples of these are SOAP/HTTP URLs, FTP Server Host,etc which will typically vary in each environment. There is already content on Externalized Parameters for HCI on SCN and would recommend you read that or the corresponding documentation from SAP - Externalizing Parameters of Integration Flow

To be able to define Logging Dynamically we will be using a custom Externalized Parameters, so you can enable and disable logging without having to make changes to your Integration Flow or the Groovy script.

Integration Flow Changes

We will continue to use the sample Integration Flow described in my previous blog with an additional Content Modifier Step and some changes in the Groovy script as described below.

Delta Changes
Content Modifier
  • The  New Content Modifier step is used to read the External Parameter into a local property.
  • Name = logger ( Message Property to be used in the Groovy Script )
  • Type = External Parameter
  • Data Type = java.lang.String
  • Value = externalParamLogger ( Name of the External Parameter whose value will be set externally )

Groovy Script Change
  • Read Message Properties
  • Read the value of property logger as set in the previous content modifier step
  • If Logger is set to 1, then log the payload else, do not perform any logging.

import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;
    def messageLog = messageLogFactory.getMessageLog(message);
    def propertyMap = message.getProperties()
    //Read logger from the Message Properties
    String logger = propertyMap.get("logger");
        if(messageLog != null){
            messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment")
            messageLog.addAttachmentAsString("ResponsePayload:", body, "text/plain");
  return message;

Setting of Externalized Parameters

Once the Content Modifier step is defined, the Externalized Parameters tab should contain the Parameter with the name as defined in our Content Modifier step. In this case: externalParamLogger. Set the default value of the Parameter as 0 (Zero). Save and Deploy your Integration Flow.

Test your flow with External Parameter Value set to 0

Trigger your Integration flow with the External Parameter Value set a 0. The Integration Flow executes and the Groovy Script does not log the payload as the value is set to 0. As seen in the image below no attachment is available.

Test your flow with External Parameter Value set to 1

To update your external parameters, navigate to Window --> Show View --> Other. In your Show View dialog box, navigate to Other --> Configurations

In the Configurations Pane that opens, navigate to your project and double click on the same. In my case the name of my project is - Prj_PayloadAsAttachment

Go to Externalized Parameters tab and update the value of externalParamLogger as 1 and click on Save Parameters

Right Click on your project in Configurations --> Deploy Integration Content. Your Integration Flow is now updated to have the Logging Enabled!

Re-trigger the Interface and you should see the logs with the attachment as the Logger is now set to Value 1.

Final Note

As seen in this blog, Externalized Parameters provide you with options to provide parameters to your Integration flow dynamically. This along with some smart Groovy Scripting enables you to dynamically control payload logging.

Labels in this area