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.
|
Append Message ID |
Determines whether the Message ID is included in the log along with other selected details.
|
Append Payload |
Determines whether the full message payload is included in the log along with other selected details.
|
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
|
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>
[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