Skip to content

Log Mediator

The Log mediator enables the logging of messages as they flow through mediation sequences. It helps in debugging and tracking messages by printing message content, variables, properties, and other relevant information to the console or a log file. It can be added at any point in the flow.

For more information on logging, see Monitoring Logs.

Syntax

<log [category="INFO|TRACE|DEBUG|WARN|ERROR|FATAL"] [separator="string"] logMessageID=(true | false) logFullPayload=(true | false)>
   <message></message>
   <property name="string" (value="string" | expression="expression")/>+
</log>

Configuration

The parameters available to configure the Log mediator are as follows.

Parameter Name Description
Log Category

This parameter is used to specify the log category. The following log levels correspond to the Micro Integrator service level logs.

  • INFO - provides informational messages that highlight the progress of the application at a coarse-grained level.
  • TRACE - provides fine-grained informational events than the DEBUG level.
  • DEBUG - provides fine-grained informational events that are most useful to debug an application.
  • WARN - provides informational messages on potentially harmful situations.
  • ERROR - provides error events that might still allow the application to continue running.
  • FATAL - provides very severe error events that will presumably lead the application to abort.

Append Message ID Determines whether the Message ID is included in the log along with other selected details.
  • True: Includes the Message ID in the log.
  • False: Excludes the Message ID from the log. (Default)
Append Payload Determines whether the full message payload is included in the log along with other selected details.
  • True: Includes the full message payload in the log.
  • False: Excludes the message payload from the log. (Default)
Message

This parameter is used to define a log message. You can embed Synapse Expressions in the template to generate the log message.

You can use the Additional Parameters section to log additional information. The configurations available under Additional Parameters section of the Log mediator are as follows.

Parameter Name Description
Parameters

This is used to specify the key value pairs to be logged. You can use the Add Parameter option to add a new parameter.

  • Name - The name of the parameter to be logged.
  • Value - Based on the use case you can either have a static value or an expression.

Parameter Separator

This parameter specifies the value used to separate parameters in the log. By default, the separator is a comma (,).

Examples

Using a message template

In this example, we define a message template using Synapse Expressions.

<log category="INFO">
   <message>Processing user details : ${payload.user} with Purchase data : ${var.purchaseDetails}</message>
</log>

A sample log output:

[2024-09-09 15:23:03,998]  INFO {LogMediator} - {api:StockQuoteAPI} Processing user details : {"firstName":"Johne", "lastName": "Doe"} with Purchase data : {"itemCode": 8987, "price": 45}

Logging message ID

In this example, we enable logging of the message ID by setting logMessageID="true" in the log configuration. Additionally, we define a message template using Synapse Expressions.

<log category="INFO" logMessageID="true">
   <message>Test message ${payload}</message>
</log>

A sample log output:

[2025-02-27 21:18:38,015]  INFO {LogMediator} - {api:TestApi POST /testapi/} MessageID: urn:uuid:7137bda5-065d-41b9-85c9-1b23b8c3fd8e, correlation_id: 7137bda5-065d-41b9-85c9-1b23b8c3fd8e, Test message {"payload":"Hello World"}

Using parameters in addition to message template

In this example, we define parameters in addition to the message.

<log category="INFO">
   <message>Processing user details : ${payload.user} with Purchase data : ${var.purchaseDetails}</message>
   <property name="endpoint" expression="${var.endpointName}"/>
</log>
A sample log output:
[2024-09-09 15:23:03,998]  INFO {LogMediator} - {api:StockQuoteAPI} Processing user details : {"firstName":"Johne", "lastName": "Doe"} with Purchase data : {"itemCode": 8987, "price": 45}, endpoint = PurchaseEP