This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Log Mediator

The Log mediator is used to log mediated messages. For more information on logging, see Monitoring Logs in WSO2 Administration Guide. 

The Log mediator is a conditionally content aware mediator.



Syntax

The log token refers to a <log> element, which may be used to log messages being mediated.

<log [level="string"] [separator="string"]>
   <property name="string" (value="literal" | expression="[XPath|json-eval(JSON Path)]")/>*
</log>

UI Configuration

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

Parameter NameDescription
Log Category

This parameter is used to specify the log category. Possible values are as follows. Following log levels correspond to the ESB profile service level logs.

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

Log Level

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

  • 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 (i.e. To, From, WSAction, SOAPAction, ReplyTo, and MessageID) will be logged.
  • Headers: If this is selected, all the SOAP header blocks are logged.
  • Custom: If this is selected, only the properties added to the Log mediator configuration will be logged.

The properties included in the Log mediator configuration will be logged regardless of the log level selected.

Log Separator

This parameter is used to specify a value to be used in the log to separate attributes. The , comma is default.

Use only the Source View to add a tab (i.e., by defining the separator="&#x9;" parameter in the syntax) or a new line (i.e., by defining the separator="&#xA;" parameter in the syntax) as the Log Separator, since the Design View does not support this.

Properties to be logged by the Log mediator can be added by clicking Add Property. The parameters available to configure a property are as follows.

Parameter NameDescription
Property NameThe name of the property to be logged.
Property Value

The possible values for this parameter are as follows:

  • 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 mediation by evaluating an expression. This expression should be entered in the Value/ Expression parameter.

Value/Expression

This parameter is used to enter a status value as the property value, or to enter an expression to evaluate the property value based on the what you entered for the Property Value parameter. When specifying a JSONPath, use the format json-eval(<JSON_PATH>), such as json-eval(getQuote.request.symbol). For more information on using JSON with the the ESB profile, see JSON Support.

You can click NameSpaces to add namespaces if you are providing an expression. Then the Namespace Editor panel would appear where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

ActionThis parameter allows the property to be deleted.

Note

You can configure the mediator using XML. Click switch to source view in the Mediator window.

Examples

Example 1 - Full log

In this example, everything is logged including the complete SOAP message.

<log level="full" xmlns="http://ws.apache.org/ns/synapse"/>

Example 2 - 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 level="custom" xmlns="http://ws.apache.org/ns/synapse">
	<property name="text"
			  expression="fn:concat('Stock price - ',get-property('stock_price'))"/>
</log>