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, 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.

  • 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.

Level

This parameter is used to specify the log level. The possible values are as follows.

  • Custom : If this is selected, only the properties added to the Log mediator configuration will be logged.
  • Full : If this is selected, all the standard headers logged at the Simple level as well as the full payload of the message will be logged. This log level causes the message content to be parsed and hence incurs a performance overhead.
  • Simple : If this is selected, the standard headers (such as To, From, WSAction, SOAPAction, ReplyTo, and MessageID) will be logged.
  • Headers : If this is selected, all the SOAP header blocks will be logged.

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.

  • Value: If this is selected, a static value would be considered as the property value and this value should be entered in the Value/Expression parameter.
  • Expression: If this is selected, the property value will be determined during the runtime by evaluating an expression. You can refer to Expressions.

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>
A sample log output:
[2024-09-09 15:25:20,891]  INFO {LogMediator} - {api:StockQuoteAPI} text = Stock price - 125.00