Log Mediator

With the log mediator, you can log messages being mediated.

Log Category

Log Mediator supports following log categories.Log messages will be logged in log4j with selected log category. The default log category is INFO

  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL

Log Levels

Log mediator has four log levels

  1. simple = To, From, WSAction, SOAPAction, ReplyTo, MessageID and any properties
  2. headers = All SOAP header blocks and any properties
  3. full = all attributes included in log level 'simple' and the SOAP envelope and any properties
  4. custom = Only properties specified to the Log mediator

Log Separator

A separator if defined will be used to separate the attributes being logged. The default separator is the ',' comma

Log Properties

With properties, user can choose any other attributes that they want to log. Imagine there is an element carrying the transaction id in the SOAP body. User can use a XPath expression to extract out this transaction id element and log it using the log mediator. It is possible to define several such properties to be logged.

If properties are specified with any of the first three log levels, custom properties will be logged along with the default ones.

Syntax

 <log [level="string"] [separator="string"]>
   <property name="string" (value="literal" | expression="xpath")/>*
 </log>

UI Configuration

Log Mediator

Figure1: Log Mediator

Log Category

You can select the log category to be one of following values.

  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL

Log Level

You can select the log level to be one of following values.

  • Simple: To, From, WSAction, SOAPAction, ReplyTo, MessageID and any properties
  • Headers: All SOAP header blocks and any properties
  • Full: All attributes included in log level 'simple' and the SOAP envelope and any properties
  • Custom: Only properties specified to the Log mediator

Log Separator

The log separator is used to separate the attributes being logged. The default separator is ',' (comma).

Adding Properties

You can add custom messages to log as the messages mediate thorough the log mediator.

Log Mediator Properties

Figure2: Log Mediator Properties

  • Property Name: Name for the property
  • Property Value: The type of the property value, possible candidates are Value/Expression
    • Value - A static text message
    • Expression - An xpath expression executed on each mediating message
  • Value: The text or an expression you want to log
  • NSEditor: You can click this link to add namespaces if you are providing an expression. You will be provided another panel named 'Namespace Editor' where you can provide any number of namespace prefixes and url that you have used in the xpath expression. Here is an example of the use of namespaces in an expression.
  • Action: Delete the property

Example

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

In this example log level is set to custom. It logs the property stock_price that is set previously in the message mediation.

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

In the previous example it logs evething including the full SOAP message.