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, 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"] [level="custom|full|simple|headers"] [separator="string"]>
<property name="string" (value="string" | expression="expression")/>+
</log>
Configuration¶
The parameters available to configure the Log mediator are as follows.
Parameter Name | Description |
---|---|
Category | This parameter is used to specify the log category. The following log levels correspond to the Micro Integrator service level logs.
|
Level |
This parameter is used to specify the log level. The possible values are as follows.
The properties included in the Log mediator configuration will be logged regardless of the log level selected. |
Separator |
This parameter specifies the value used to separate attributes in the log. By default, the separator is a comma ( |
You can add properties inside the Log mediator to log additional information. The parameters available to configure a property are as follows:
Parameter Name | Description |
---|---|
Property Name | The name of the property to be logged. |
Value/Expression | Based on the use case you can select either value or expression.
|
Examples¶
Use full log¶
In this example, everything is logged including the complete message.
<log category="INFO" level="full"/>
A sample log output:
[2024-09-09 15:23:03,998] INFO {LogMediator} - {api:StockQuoteAPI} To: /stockQuote/getQuote, MessageID: urn:uuid:1f871a99-c7cc-4497-a767-945e4d5fd2c8, correlation_id: 1f871a99-c7cc-4497-a767-945e4d5fd2c8, Direction: request, Payload: { "symbol" : "IBM"}
Use custom logs¶
In this example, the log level is custom
. A property
with an XPath expression which is used to get a stock price from a
message is included. This results in logging the stock price which is a
dynamic value.
<log category="INFO" level="custom">
<property name="text" expression="fn:concat('Stock price - ',get-property('stock_price'))"/>
</log>
[2024-09-09 15:25:20,891] INFO {LogMediator} - {api:StockQuoteAPI} text = Stock price - 125.00