CPI Groovy Examples

Go to List of Examples

MPL Payload Log

Basic MPL logging to see the payload in the monitoring.

You don't have to import any library to use messageLogFactory. It is already "injected" to your script.


Try it on Groovy IDE
import com.sap.gateway.ip.core.customdev.util.Message;

def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String;

    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){

        messageLog.setStringProperty("Logging", "Printing Payload As Attachment");
        messageLog.addAttachmentAsString("Message#1", body, "text/plain");

    return message;