<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <title>WSO2 ESB - Log Mediator </title>
  <link href="css/esb-docs.css" rel="stylesheet" />
  <link href="styles/dist-docs.css" rel="stylesheet" type="text/css"
  media="all" />
</head>

<body>
<h2>Log Mediator</h2>

<p>With the log mediator, you can log messages being mediated. </p>

<p><strong>Log Category</strong> </p>
<p>Log Mediator supports following log categories.Log messages will be logged in log4j with
selected log category. The default log category is INFO</p> 
<ul>
    <li>TRACE</li>
    <li>DEBUG</li>
    <li>INFO</li>
    <li>WARN</li>
    <li>ERROR</li>
    <li>FATAL</li>
</ul>


<p><strong>Log Levels</strong> </p>    
<p>Log mediator has four log levels</p>
<ol>
  <li>simple = To, From, WSAction, SOAPAction, ReplyTo, MessageID and any
    properties</li>
  <li>headers = All SOAP header blocks and any properties</li>
  <li>full = all attributes included in log level 'simple' and the SOAP
    envelope and any properties</li>
  <li>custom = Only properties specified to the Log mediator</li>
</ol>

<p><strong>Log Separator</strong></p>   

<p>A separator if defined will be used to separate the attributes being logged.
The default separator is the ',' comma</p>
                            
<p><strong>Log Properties</strong> </p>
<p>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.</p>

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

<h3>Syntax</h3>
<pre xml:space="preserve"> &lt;log [level="string"] [separator="string"]&gt;
   &lt;property name="string" (value="literal" | expression="xpath")/&gt;*
 &lt;/log&gt;</pre>

<h3>UI Configuration</h3>

<p><img alt="Log Mediator"
src="../log-mediator/docs/images/log_mediator_screenshot.jpg" /> </p>

<p><strong>Figure1: Log Mediator</strong> </p>

<h4>Log Category</h4>
<p>You can select the log category to be one of following values. </p>
<ul>
    <li>TRACE</li>
    <li>DEBUG</li>
    <li>INFO</li>
    <li>WARN</li>
    <li>ERROR</li>
    <li>FATAL</li>
</ul>

<h4>Log Level</h4>
<p>You can select the log level to be one of following values. </p>
<ul>
  <li>Simple: To, From, WSAction, SOAPAction, ReplyTo, MessageID and any
    properties</li>
  <li>Headers: All SOAP header blocks and any properties</li>
  <li>Full: All attributes included in log level 'simple' and the SOAP envelope
    and any properties</li>
  <li>Custom: Only properties specified to the Log mediator</li>
</ul>

<h4>Log Separator</h4>

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

<h4>Adding Properties</h4>

<p>You can add custom messages to log as the messages mediate thorough the log
mediator. </p>

<p><img alt="Log Mediator Properties"
src="../log-mediator/docs/images/log_mediator_properties_screenshot.jpg" /> </p>

<p><strong>Figure2: Log Mediator Properties</strong> </p>
<ul>
  <li>Property Name: Name for the property </li>
  <li>Property Value: The type of the property value, possible candidates are
    Value/Expression 
    <ul>
      <li>Value - A static text message </li>
      <li>Expression - An xpath expression executed on each mediating message
      </li>
    </ul>
  </li>
  <li>Value: The text or an expression you want to log </li>
  <li>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. </li>
  <li>Action: Delete the property </li>
</ul>

<h3>Example</h3>
<pre xml:space="preserve">  &lt;log level="custom" xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;property name="text"
                expression="fn:concat('Stock price - ',get-property('stock_price'))"/&gt;
  &lt;/log&gt;</pre>

<p>In this example log level is set to custom. It logs the property stock_price
that is set previously in the message mediation.</p>
<pre xml:space="preserve"> 
  &lt;log level="full" xmlns="http://ws.apache.org/ns/synapse"/&gt;</pre>

<p>In the previous example it logs evething including the full SOAP message.</p>
</body>
</html>
