Skip to content

Commit 839d2e2

Browse files
committed
SWS-319
1 parent 11d4262 commit 839d2e2

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/docbkx/common.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,52 @@ public class MyXPathClass {
384384
}]]></programlisting>
385385
</section>
386386
</section>
387+
<section id="logging">
388+
<title>Message Logging and Tracing</title>
389+
<para>
390+
When developing or debugging a Web service, it can be quite useful to look at the content of a (SOAP)
391+
message when it arrives, or just before it is sent. Spring Web Services offer this functionality, via the
392+
standard Commons Logging interface.
393+
</para>
394+
<caution>
395+
<para>
396+
Make sure to use Commons Logging version 1.1 or higher. Earlier versions have class loading issues, and
397+
do not integrate with the Log4J TRACE level.
398+
</para>
399+
</caution>
400+
<para>
401+
To log all server-side messages, simply set the
402+
<literal>org.springframework.ws.server.MessageTracing</literal> logger to level DEBUG or TRACE. On the debug
403+
level, only the payload root element is logged; on the TRACE level, the entire message content.
404+
If you only want to log sent messages, use the
405+
<literal>org.springframework.ws.server.MessageTracing.sent</literal> logger; or
406+
<literal>org.springframework.ws.server.MessageTracing.received</literal> to log received messages.
407+
</para>
408+
<para>
409+
On the client-side, similar loggers exist:
410+
<literal>org.springframework.ws.client.MessageTracing.sent</literal> and
411+
<literal>org.springframework.ws.client.MessageTracing.received</literal>.
412+
</para>
413+
<para>
414+
Here is an example <filename>log4j.properties</filename> configuration, logging the full content of
415+
sent messages on the client side, and only the payload root element for client-side received messages. On
416+
the server-side, the payload root is logged for both sent and received messages:
417+
</para>
418+
<programlisting><![CDATA[log4j.rootCategory=INFO, stdout
419+
log4j.logger.org.springframework.ws.client.MessageTracing.sent=TRACE
420+
log4j.logger.org.springframework.ws.client.MessageTracing.received=DEBUG
421+
422+
log4j.logger.org.springframework.ws.server.MessageTracing=DEBUG
423+
424+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
425+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
426+
log4j.appender.stdout.layout.ConversionPattern=%p [%c{3}] %m%n]]></programlisting>
427+
<para>
428+
With this configuration, a typical output will be:
429+
</para>
430+
<screen><![CDATA[TRACE [client.MessageTracing.sent] Sent request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="...
431+
DEBUG [server.MessageTracing.received] Received request [SaajSoapMessage {http://example.com}request] ...
432+
DEBUG [server.MessageTracing.sent] Sent response [SaajSoapMessage {http://example.com}response] ...
433+
DEBUG [client.MessageTracing.received] Received response [SaajSoapMessage {http://example.com}response] ...]]></screen>
434+
</section>
387435
</chapter>

0 commit comments

Comments
 (0)