camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Log
Date Thu, 04 Feb 2010 06:12:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Log">Log</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="Log-LogComponent"></a>Log Component</h2>

<p>The <b>log:</b> component logs message exchanges to the underlying logging
mechanism.</p>

<p>Camel uses <a href="http://commons.apache.org/logging/" rel="nofollow">commons-logging</a>
which allows you to configure logging via </p>

<ul>
	<li><a href="http://logging.apache.org/log4j/" rel="nofollow">Log4j</a></li>
	<li><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/package-summary.html"
rel="nofollow">JDK 1.4 logging</a></li>
	<li>Avalon</li>
	<li>SimpleLog - a simple provider in commons-logging</li>
</ul>


<p>Refer to the <a href="http://commons.apache.org/logging/commons-logging-1.1.1/guide.html"
rel="nofollow">commons-logging user guide</a> for a more complete overview of how
to use and configure commons-logging.</p>


<h3><a name="Log-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
log:loggingCategory[?options]
</pre>
</div></div>

<p>Where <b>loggingCategory</b> is the name of the logging category to use.
You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<p>For example, a log endpoint typically specifies the logging level using the <tt>level</tt>
option, as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
log:org.apache.camel.example?level=DEBUG
</pre>
</div></div>

<p>The default logger logs every exchange (<em>regular logging</em>). But
Camel also ships with the <tt>Throughput</tt> logger, which is used whenever the
<tt>groupSize</tt> option is specified.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Also a log in the DSL</b><br
/><p>In <b>Camel 2.2</b> onwards there is a <tt>log</tt>
directly in the DSL, but it has a different purpose. Its meant for lightweight and human logs.
See more details at <a href="/confluence/display/CAMEL/LogEIP" title="LogEIP">LogEIP</a>.</p></td></tr></table></div>

<h3><a name="Log-Options"></a>Options</h3>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>level</tt> </td>
<td class='confluenceTd'> <tt>INFO</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Logging level to use. Possible values: <tt>FATAL</tt>,
<tt>ERROR</tt>, <tt>WARN</tt>, <tt>INFO</tt>, <tt>DEBUG</tt>,
<tt>TRACE</tt>, <tt>OFF</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>groupSize</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <tt>Integer</tt> </td>
<td class='confluenceTd'> An integer that specifies a group size for throughput logging.
By default, regular logging is used. </td>
</tr>
</tbody></table>

<h3><a name="Log-Formatting"></a>Formatting</h3>
<p>The log formats the execution of exchanges to log lines. <br/>
By default, the log uses <tt>LogFormatter</tt> to format the log output, where
<tt>LogFormatter</tt> has the following options:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>showAll</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Quick option for turning all options on. (multiline, maxChars
has to be manually set if to be used) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showExchangeId</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Show the unique exchange ID. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showProperties</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Show the exchange properties. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showHeaders</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Show the In message headers. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showBodyType</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Show the In body Java type. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showBody</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Show the In body. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showOut</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If the exchange has an Out message, show the Out message.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showException</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> If the exchange has an exception,
show the exception message (no stack trace). </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showCaughtException</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> If the exchange has a caught
exception, show the exception message (no stack trace). A caught exception is stored as a
property on the exchange and for instance a <tt>doCatch</tt> can catch exceptions.
See <a href="/confluence/display/CAMEL/Try+Catch+Finally" title="Try Catch Finally">Try
Catch Finally</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showStackTrace</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> Show the stack trace, if an
exchange has an exception. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>showFuture</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.1:</b> Whether Camel should show <tt>java.util.concurrent.Future</tt>
bodies or not. If enabled Camel could potentially wait until the <tt>Future</tt>
task is done. Will by default not wait. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>multiline</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If <tt>true</tt>, each piece of information is
logged on a new line. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>maxChars</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>Camel 2.0:</b> Limits the number of characters
logged per line. </td>
</tr>
</tbody></table>

<h3><a name="Log-Regularloggersample"></a>Regular logger sample</h3>
<p>In the route below we log the incoming orders at <tt>DEBUG</tt> level
before the order is processed:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:orders"</span>).to(<span class="code-quote">"log:com.mycompany.order?level=DEBUG"</span>).to(<span
class="code-quote">"bean:processOrder"</span>);
</pre>
</div></div>

<p>Or using Spring XML to define the route:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"activemq:orders"</span>/&gt;</span>
    <span class="code-tag">&lt;to uri=<span class="code-quote">"log:com.mycompany.order?level=DEBUG"</span>/&gt;</span>
    <span class="code-tag">&lt;to uri=<span class="code-quote">"bean:processOrder"</span>/&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span> 
</pre>
</div></div>

<h3><a name="Log-Regularloggerwithformattersample"></a>Regular logger with
formatter sample</h3>
<p>In the route below we log the incoming orders at <tt>INFO</tt> level
before the order is processed.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:orders"</span>).
    to(<span class="code-quote">"log:com.mycompany.order?showAll=<span class="code-keyword">true</span>&amp;multiline=<span
class="code-keyword">true</span>"</span>).to(<span class="code-quote">"bean:processOrder"</span>);
</pre>
</div></div>

<h3><a name="Log-Throughputloggersample"></a>Throughput logger sample</h3>
<p>In the route below we log the throughput of the incoming orders at <tt>DEBUG</tt>
level grouped by 10 messages.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:orders"</span>).
    to(<span class="code-quote">"log:com.mycompany.order?level=DEBUG?groupSize=10"</span>).to(<span
class="code-quote">"bean:processOrder"</span>);
</pre>
</div></div>

<h3><a name="Log-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Tracer" title="Tracer">Tracer</a></li>
	<li><a href="/confluence/display/CAMEL/How+do+I+use+log4j" title="How do I use log4j">How
do I use log4j</a></li>
	<li><a href="/confluence/display/CAMEL/How+do+I+use+Java+1.4+logging" title="How
do I use Java 1.4 logging">How do I use Java 1.4 logging</a></li>
	<li><a href="/confluence/display/CAMEL/LogEIP" title="LogEIP">LogEIP</a>
for using <tt>log</tt> directly in the DSL for human logs.</li>
</ul>


     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Log">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=63040&revisedVersion=19&originalVersion=18">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Log?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message