You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2015/12/04 08:47:30 UTC

svn commit: r974485 - in /websites/production/cxf/content: cache/docs.pageCache docs/message-logging.html

Author: buildbot
Date: Fri Dec  4 07:47:30 2015
New Revision: 974485

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/message-logging.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/message-logging.html
==============================================================================
--- websites/production/cxf/content/docs/message-logging.html (original)
+++ websites/production/cxf/content/docs/message-logging.html Fri Dec  4 07:47:30 2015
@@ -117,19 +117,22 @@ Apache CXF -- Message Logging
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><div class="container" title="Hint: double-click to select code"><p>Since CXF 3.1 the message logging code was moved into a separate module and gathered some new features.</p><ul><li>Auto logging for existing CXF endpoints</li><li>Uses slf4j MDC to log meta data separately</li><li>Adds meta data for Rest calls</li><li>Adds MD5 message id and exchange id for correlation</li><li>Simple interface for writing your own appenders</li></ul><h2 id="MessageLogging-ManualUsage">Manual Usage</h2><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CXF LoggingFeature</b></div><div class="codeContent panelContent pdl">
+<div id="ConfluenceContent"><div class="container" title="Hint: double-click to select code"><p>Since CXF 3.1 the message logging code was moved into a separate module and gathered some new features.</p><ul><li>Auto logging for existing CXF endpoints and clients</li><li>Uses slf4j MDC to log meta data separately</li><li>Adds meta data for Rest calls</li><li>Adds MD5 message id and exchange id for correlation</li><li>Simple interface for writing your own appenders</li></ul><h2 id="MessageLogging-ManualUsage">Manual Usage</h2><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CXF LoggingFeature</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">    &lt;jaxws:endpoint ...&gt;
       &lt;jaxws:features&gt;
        &lt;bean class="org.apache.cxf.ext.logging.LoggingFeature"/&gt;
       &lt;/jaxws:features&gt;
     &lt;/jaxws:endpoint&gt;</pre>
-</div></div><p>The LoggingFeature can also be used with JAXRS Endpoints and can also be specified using the @Features annoation.</p><h2 id="MessageLogging-AutologgingforexistingCXFendpointsinApacheKaraf">Auto logging for existing CXF endpoints in Apache Karaf</h2><p>To use the message logging in karaf it needs to be installed as a feature. It can then be activated for all endpoints using a config.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Logging feature in karaf</b></div><div class="codeContent panelContent pdl">
+</div></div><p>The LoggingFeature can be used with JAXWS as well JAXRS Endpoints and Clients. It can also be specified using the @Features annotation.</p><h2 id="MessageLogging-Slf4jMDCvaluesformetadata">Slf4j MDC values for meta data</h2><p>This is the raw logging information you get for a SOAP call:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Field</th><th colspan="1" rowspan="1" class="confluenceTh">Value</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">@timestamp</td><td colspan="1" rowspan="1" class="confluenceTd">2015-06-08T14:43:27,097Z</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.address</td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://localhost:8181/cxf/personService" rel="nofollow">http://localhost:8181/cxf/personService</a></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="exte
 rnal-link" href="http://MDC.bundle.id" rel="nofollow">MDC.bundle.id</a></td><td colspan="1" rowspan="1" class="confluenceTd">90</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://MDC.bundle.name" rel="nofollow">MDC.bundle.name</a></td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.cxf-rt-features-logging</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.bundle.version</td><td colspan="1" rowspan="1" class="confluenceTd">3.1.0</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.content-type</td><td colspan="1" rowspan="1" class="confluenceTd">text/xml; charset=UTF-8</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.encoding</td><td colspan="1" rowspan="1" class="confluenceTd">UTF-8</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.exchangeId</td><td colspan="1" rowspan="1" class="confluenceTd">56b037e3-d254-4fe5-8723-f442835fa128</td></tr><tr><t
 d colspan="1" rowspan="1" class="confluenceTd">MDC.headers</td><td colspan="1" rowspan="1" class="confluenceTd">{content-type=text/xml; charset=UTF-8, connection=keep-alive, Host=localhost:8181, Content-Length=251, SOAPAction="", User-Agent=Apache CXF 3.1.0, Accept=*/*, Pragma=no-cache, Cache-Control=no-cache}</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.httpMethod</td><td colspan="1" rowspan="1" class="confluenceTd">POST</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.messageId</td><td colspan="1" rowspan="1" class="confluenceTd">a46eebd2-60af-4975-ba42-8b8205ac884c</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.portName</td><td colspan="1" rowspan="1" class="confluenceTd">PersonServiceImplPort</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.portTypeName</td><td colspan="1" rowspan="1" class="confluenceTd">PersonService</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.serviceName</td><td co
 lspan="1" rowspan="1" class="confluenceTd">PersonServiceImplService</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.type</td><td colspan="1" rowspan="1" class="confluenceTd">REQ_IN</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">level</td><td colspan="1" rowspan="1" class="confluenceTd">INFO</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.class</td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.ext.logging.slf4j.Slf4jEventSender</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.file</td><td colspan="1" rowspan="1" class="confluenceTd">Slf4jEventSender.java</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.line</td><td colspan="1" rowspan="1" class="confluenceTd">55</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.method</td><td colspan="1" rowspan="1" class="confluenceTd">send</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loggerClass</td><td colspan="1"
  rowspan="1" class="confluenceTd">org.ops4j.pax.logging.slf4j.Slf4jLogger</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loggerName</td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.services.PersonService.REQ_IN</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">message</td><td colspan="1" rowspan="1" class="confluenceTd">&lt;soap:Envelope xmlns:soap="<a shape="rect" class="external-link" href="http://schemas.xmlsoap.org/soap/envelope/%22%3E%3Csoap:Body%3E%3Cns2:getAll" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;ns2:getAll</a> xmlns:ns2="<a shape="rect" class="external-link" href="http://model.personservice.cxf.karaf.tutorial.lr.net/%22" rel="nofollow">http://model.personservice.cxf.karaf.tutorial.lr.net/"</a>; xmlns:ns3="<a shape="rect" class="external-link" href="http://person.jms2rest.camel.karaf.tutorial.lr.net%22/%3E%3C/soap:Body%3E%3C/soap:Envelope%3E" rel="nofollow">http://person.jms2rest.camel
 .karaf.tutorial.lr.net"/&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;</a>;</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">threadName</td><td colspan="1" rowspan="1" class="confluenceTd">qtp80604361-78</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">timeStamp</td><td colspan="1" rowspan="1" class="confluenceTd">1433774607097</td></tr></tbody></table></div><p>Some things to note:</p><ul><li>The logger name is &lt;service namespace&gt;.&lt;ServiceName&gt;.&lt;type&gt; karaf by default only cuts it to just the type.</li><li>A lot of the details are in the MDC values</li></ul><p>You need to change your pax logging config to make these visible.</p><p>You can use the logger name to fine tune which services you want to log this way. For example set the debug level to WARN for noisy services to avoid that they are logged or log some services to another file.</p><h2 id="MessageLogging-Messageidandexchangeid">Message id and exchange id</h2><p>The messageId allows to
  uniquely identify messages even if they were collected from several servers. It is also transported over the wire so a request sent on one machine can be correlated with the request received on another machine.</p><p>The exchangeId will be the same for an incoming request and the response sent out or on the other side for an outgoing request and the response for it. This allows to correlate request and responses and so follow the conversations.</p><h2 id="MessageLogging-Simpleinterfacetowritecustomappenders">Simple interface to write custom appenders</h2><p>Write a custom <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java" rel="nofollow">LogSender</a> and set it on the <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java" rel="nofollow">LoggingFeatur
 e</a> to do custom logging. All meta data can be access from the class <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEvent.java" rel="nofollow">LogEvent</a>.</p><h2 id="MessageLogging-AutologgingforexistingCXFendpointsandclientsinApacheKaraf">Auto logging for existing CXF endpoints and clients in Apache Karaf</h2><p>To use the message logging in karaf it needs to be installed as a feature. It can then be activated for all endpoints using a config.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Logging feature in karaf</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: bash; gutter: false; theme: Default" style="font-size:12px;">feature:repo-add cxf 3.1.0
 feature:install cxf-features-logging
 config:property-set -p org.apache.cxf.features.logging enabled true</pre>
 </div></div><p>Any CXF endpoints installed after the logging feature will automatically be enhanced with the message logging feature.</p>By default then all SOAP and Rest calls will be logged using slf4j. So the logging data will be processed by pax logging and by default end up in your karaf log.<p>A log entry looks like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Sample Log entry</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: bash; gutter: false; theme: Default" style="font-size:12px;">2015-06-08 16:35:54,068 | INFO  | qtp1189348109-73 | REQ_IN                           | 90 - org.apache.cxf.cxf-rt-features-logging - 3.1.0 | &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;ns2:addPerson xmlns:ns2="http://model.personservice.cxf.karaf.tutorial.lr.net/" xmlns:ns3="http://person.jms2rest.camel.karaf.tutorial.lr.net"&gt;&lt;arg0&gt;&lt;id&gt;3&lt;/id&gt;&lt;name&gt;Test2&lt;/name&gt;&lt;url&gt;&lt;/url&gt;&lt;/arg0&gt;&lt;/ns2:addPerson&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;</pre>
-</div></div><p>This does not look very informative. You only see that it is an incoming request (REQ_IN) and the SOAP message in the log message. The logging feature provides a lot more information though. To leverage these the pax logging config can be changed to show the relevant MDC values.</p><h2 id="MessageLogging-Slf4jMDCvaluesformetadata">Slf4j MDC values for meta data</h2><p>This is the raw logging information you get for a SOAP call:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Field</th><th colspan="1" rowspan="1" class="confluenceTh">Value</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">@timestamp</td><td colspan="1" rowspan="1" class="confluenceTd">2015-06-08T14:43:27,097Z</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.address</td><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://localhost:8181/cxf/personService" rel=
 "nofollow">http://localhost:8181/cxf/personService</a></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://MDC.bundle.id" rel="nofollow">MDC.bundle.id</a></td><td colspan="1" rowspan="1" class="confluenceTd">90</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" class="external-link" href="http://MDC.bundle.name" rel="nofollow">MDC.bundle.name</a></td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.cxf-rt-features-logging</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.bundle.version</td><td colspan="1" rowspan="1" class="confluenceTd">3.1.0</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.content-type</td><td colspan="1" rowspan="1" class="confluenceTd">text/xml; charset=UTF-8</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.encoding</td><td colspan="1" rowspan="1" class="confluenceTd">UTF-8</td></tr><tr><td colspan="1" rowspan="
 1" class="confluenceTd">MDC.exchangeId</td><td colspan="1" rowspan="1" class="confluenceTd">56b037e3-d254-4fe5-8723-f442835fa128</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.headers</td><td colspan="1" rowspan="1" class="confluenceTd">{content-type=text/xml; charset=UTF-8, connection=keep-alive, Host=localhost:8181, Content-Length=251, SOAPAction="", User-Agent=Apache CXF 3.1.0, Accept=*/*, Pragma=no-cache, Cache-Control=no-cache}</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.httpMethod</td><td colspan="1" rowspan="1" class="confluenceTd">POST</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.messageId</td><td colspan="1" rowspan="1" class="confluenceTd">a46eebd2-60af-4975-ba42-8b8205ac884c</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.portName</td><td colspan="1" rowspan="1" class="confluenceTd">PersonServiceImplPort</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.portTypeName</td><td col
 span="1" rowspan="1" class="confluenceTd">PersonService</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.serviceName</td><td colspan="1" rowspan="1" class="confluenceTd">PersonServiceImplService</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">MDC.type</td><td colspan="1" rowspan="1" class="confluenceTd">REQ_IN</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">level</td><td colspan="1" rowspan="1" class="confluenceTd">INFO</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.class</td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.ext.logging.slf4j.Slf4jEventSender</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.file</td><td colspan="1" rowspan="1" class="confluenceTd">Slf4jEventSender.java</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.line</td><td colspan="1" rowspan="1" class="confluenceTd">55</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loc.method</td><td
  colspan="1" rowspan="1" class="confluenceTd">send</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loggerClass</td><td colspan="1" rowspan="1" class="confluenceTd">org.ops4j.pax.logging.slf4j.Slf4jLogger</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">loggerName</td><td colspan="1" rowspan="1" class="confluenceTd">org.apache.cxf.services.PersonService.REQ_IN</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">message</td><td colspan="1" rowspan="1" class="confluenceTd">&lt;soap:Envelope xmlns:soap="<a shape="rect" class="external-link" href="http://schemas.xmlsoap.org/soap/envelope/%22%3E%3Csoap:Body%3E%3Cns2:getAll" rel="nofollow">http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;ns2:getAll</a> xmlns:ns2="<a shape="rect" class="external-link" href="http://model.personservice.cxf.karaf.tutorial.lr.net/%22" rel="nofollow">http://model.personservice.cxf.karaf.tutorial.lr.net/"</a>; xmlns:ns3="<a shape="rect" class="external-link" 
 href="http://person.jms2rest.camel.karaf.tutorial.lr.net%22/%3E%3C/soap:Body%3E%3C/soap:Envelope%3E" rel="nofollow">http://person.jms2rest.camel.karaf.tutorial.lr.net"/&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;</a>;</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">threadName</td><td colspan="1" rowspan="1" class="confluenceTd">qtp80604361-78</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">timeStamp</td><td colspan="1" rowspan="1" class="confluenceTd">1433774607097</td></tr></tbody></table></div><p>Some things to note:</p><ul><li>The logger name is &lt;service namespace&gt;.&lt;ServiceName&gt;.&lt;type&gt; karaf by default only cuts it to just the type.</li><li>A lot of the details are in the MDC values</li></ul><p>You need to change your pax logging config to make these visible.</p><p>You can use the logger name to fine tune which services you want to log this way. For example set the debug level to WARN for noisy services to avoid that they are logged o
 r log some services to another file.</p><h2 id="MessageLogging-Messageidandexchangeid">Message id and exchange id</h2><p>The messageId allows to uniquely identify messages even if they were collected from several servers. It is also transported over the wire so a request sent on one machine can be correlated with the request received on another machine.</p><p>The exchangeId will be the same for an incoming request and the response sent out or on the other side for an outgoing request and the response for it. This allows to correlate request and responses and so follow the conversations.</p><h2 id="MessageLogging-Simpleinterfacetowritecustomappenders">Simple interface to write custom appenders</h2><p>Write a custom <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java" rel="nofollow">LogSender</a> and set it on the <a shape="rect" class="external-link" href="https://
 github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java" rel="nofollow">LoggingFeature</a> to do custom logging. All meta data can be access from the class <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEvent.java" rel="nofollow">LogEvent</a>.</p><p>&#160;</p></div></div>
+</div></div><p>This does not look very informative. You only see that it is an incoming request (REQ_IN) and the SOAP message in the log message. The logging feature provides a lot more information though. To leverage these the pax logging config can be changed to show the relevant MDC values.</p><h2 id="MessageLogging-Karafdecantersupporttowriteintoelasticsearch">Karaf decanter support to write into elastic search</h2><p>Many people use elastic search for their logging. Fortunately you do not have to write a special LogSender for this purpose. The standard CXF logging feature will already work.</p><p>It works like this:</p><ul><li>CXF sends the messages as slf4j events which are processed by pax logging</li><li>Karaf Decanter LogCollector attaches to pax logging and sends all log events into the karaf message bus (EventAdmin topics)</li><li>Karaf Decanter ElasticSearchAppender sends the log events to a configurable elastic search instance</li></ul><p>As Decanter also provides featu
 res for a local elastic search and kibana instance you are ready to go in just minutes.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Installing Decanter for CXF Logging</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: bash; gutter: false; theme: Default" style="font-size:12px;">feature:repo-add mvn:org.apache.karaf.decanter/apache-karaf-decanter/3.0.0-SNAPSHOT/xml/features
+feature:install decanter-collector-log decanter-appender-elasticsearch elasticsearch kibana</pre>
+</div></div><p><br clear="none">After that open a browser at <a shape="rect" class="external-link" href="http://localhost:8181/kibana" rel="nofollow">http://localhost:8181/kibana</a>. When decanter is released kibana will be fully set up. At the moment you have to add the logstash dashboard and change the index name to <strong>[karaf-]YYYY.MM.DD</strong>.</p><p>Then you should see your cxf messages like this:</p><p><span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"><img class="confluence-embedded-image confluence-external-resource" width="500" src="http://www.liquid-reality.de/download/attachments/13860866/Screenshot%20from%202015-06-08%2017%3A21%3A20.png?version=1&amp;modificationDate=1433777354000&amp;api=v2" data-image-src="http://www.liquid-reality.de/download/attachments/13860866/Screenshot%20from%202015-06-08%2017%3A21%3A20.png?version=1&amp;modificationDate=1433777354000&amp;api=v2"></span></p><p>Kibana easily allows to filter for specific services
  and correlate requests and responses.</p><p>This is just a preview of decanter. I will do a more detailed post when the first release is out.</p><br clear="none"><br clear="none"><p>&#160;</p></div></div>
            </div>
            <!-- Content -->
          </td>