This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

With the Log Mediator, you can log mediated messages. For more information on logging in the ESB, see Logging.



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 following options for the Log mediator are available:

General Options of the Log Mediator:
  • Log Category- You can select the log category to be one of the following values. Following log levels correspond to ESB service level logs.
    • TRACE - Designates fine-grained informational events than the DEBUG.
    • DEBUG - Designates fine-grained informational events that are most useful to debug an application.
    • INFO - Designates informational messages that highlight the progress of the application at coarse-grained level.
    • WARN - Designates potentially harmful situations.
    • ERROR - Designates error events that might still allow the application to continue running.
    • FATAL - Designates very severe error events that will presumably lead the application to abort.

      Tip

      You can add or edit the /repository/conf/log4j.properties file to select the category you want to log per service. The default log category is INFO.

  • Log Level- The Log mediator has four log levels:
    • Simple - To, From, WSAction, SOAPAction, ReplyTo, MessageID and any properties.
    • Headers - All SOAP header blocks and any properties.
    • Full - All attributes are included in log level "simple", the SOAP envelope and any properties.
    • Custom - The 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
Properties of the Log Mediator

With properties, users can choose any other attributes that they want to log. Imagine there is an element carrying the transaction ID in the SOAP body. You could use an XPath expression to extract 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.

Properties Characteristics:

  • Property Name - Name for the property.
  • Property Value- The type of the property value you will specify:
    • Value - A static text message.
    • Expression - An XPath or JSONPath expression executed on each message.
  • Value/Expression - The text or expression you want to log. 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 ESB, see JSON Support.
  • Name Space Editor - You can click on the "Namespaces" 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 expression.

  • Action - Deletes the property.

Note

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


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, the log level is set to custom. It logs the property stock_price that was set previously in the message mediation.

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

In the example, it logs everything including the full SOAP message.

  • No labels