Saturday, August 3, 2024

Log Trace

In this blog, I want to share important points of Log Trace for IFLOWS.

Log level in SAP Cloud Platform Integration (CPI) is a critical setting that determines the amount of detail captured in the Message Processing Log (MPL). It directly impacts the troubleshooting and monitoring capabilities of your integration 

Log levels in CPI include:

NONE: No data is recorded.   

INFO: Basic information about message processing steps and detailed information about the last processing step for failed messages.  

ERROR: Logs are created for failed executions only

DEBUG

Detailed information will be recorded for all steps during processing.
It should be used in test environments only.
Log Level 'Debug' expires after a configured time period, typically 24 hours.
After expiry the log level switches back to the previous log level 'Info'.

TRACE

Extremely detailed information, including internal system data.
It should be used in test environments only.
Log Level 'Trace' expires after a configured time period, typically 10 mins.
After expiry the log level switches back to the previous log level 'Info'.
Trace data is removed after the configured retention period, typically 1 hour.

Groovy script will be used to store a message payload as an MPL attachment in case an MPL log level 
is DEBUG or TRACE



import com.sap.gateway.ip.core.customdev.util.Message

Message processData(Message message) {

    String logLevel = message.getProperty('SAP_MessageProcessingLogConfiguration').logLevel.toString()

    if (logLevel in ['DEBUG', 'TRACE']) {
        messageLogFactory.getMessageLog(message)?.addAttachmentAsString('Payload', message.getBody(String), 'text/plain')
    }

    return message

}

Whenever you change the Log level to either DEBUG or TRACE, then payload will be logged as an attachment.



Important points to remember:
  • INFO level is often sufficient for identifying general issues and error points.  
  • For complex or intermittent problems, increasing the log level to DEBUG or TRACE can provide invaluable insights into the message flow and potential root causes.
  • High log levels can impact performance, especially in production environments.
  • Balancing detailed logging with performance considerations is essential.
  • Sensitive data might be logged at higher levels. So carefully consider the information logged, especially in production environments.
  • Log data can be used for monitoring integration flow health and performance.
  • Appropriate log levels ensure you have the necessary data for monitoring.


Thanks for reading :-)

No comments:

Post a Comment

Raise Fault Policy | API Management

What is Raise Fault Policy..? The RaiseFault policy allows you to create custom messages in case of error conditions. This policy returns a ...