Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.17.6. Logging Message Content
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
You can log the content of the messages that are sent between a service and a consumer. For example, you might want to log the contents of SOAP messages that are being sent between a service and a consumer.
Configuring message content logging Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To log the messages that are sent between a service and a consumer, and vice versa, complete the following steps:
Adding the logging feature to an endpoint Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Add the logging feature your endpoint's configuration as shown in Example 17.11, “Adding Logging to Endpoint Configuration”.
Example 17.11. Adding Logging to Endpoint Configuration
<jaxws:endpoint ...> <jaxws:features> <bean class="org.apache.cxf.feature.LoggingFeature"/> </jaxws:features> </jaxws:endpoint>
<jaxws:endpoint ...>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
</jaxws:endpoint>
The example XML shown in Example 17.11, “Adding Logging to Endpoint Configuration” enables the logging of SOAP messages.
Adding the logging feature to a consumer Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Add the logging feature your client's configuration as shown in Example 17.12, “Adding Logging to Client Configuration”.
Example 17.12. Adding Logging to Client Configuration
<jaxws:client ...> <jaxws:features> <bean class="org.apache.cxf.feature.LoggingFeature"/> </jaxws:features> </jaxws:client>
<jaxws:client ...>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
</jaxws:client>
The example XML shown in Example 17.12, “Adding Logging to Client Configuration” enables the logging of SOAP messages.
Set logging to log INFO level messages Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Ensure that the
logging.properties
file associated with your service is configured to log INFO
level messages, as shown in Example 17.13, “Setting the Logging Level to INFO”.
Example 17.13. Setting the Logging Level to INFO
.level= INFO java.util.logging.ConsoleHandler.level = INFO
.level= INFO
java.util.logging.ConsoleHandler.level = INFO
Logging SOAP messages Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To see the logging of SOAP messages modify the wsdl_first sample application located in the
InstallDir/samples/wsdl_first
directory, as follows:
- Add the
jaxws:features
element shown in Example 17.14, “Endpoint Configuration for Logging SOAP Messages” to thecxf.xml
configuration file located in the wsdl_first sample's directory:Example 17.14. Endpoint Configuration for Logging SOAP Messages
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The sample uses the default
logging.properties
file, which is located in theInstallDir/etc
directory. Make a copy of this file and name itmylogging.properties
. - In the
mylogging.properties
file, change the logging levels toINFO
by editing the.level
and thejava.util.logging.ConsoleHandler.level
configuration properties as follows:.level= INFO java.util.logging.ConsoleHandler.level = INFO
.level= INFO java.util.logging.ConsoleHandler.level = INFO
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the server using the new configuration settings in both the
cxf.xml
file and themylogging.properties
file as follows:Expand Platform Command Windows start java -Djava.util.logging.config.file=%CXF_HOME%\etc\mylogging.properties demo.hw.server.Server
UNIX java -Djava.util.logging.config.file=$CXF_HOME/etc/mylogging.properties demo.hw.server.Server &
- Start the hello world client using the following command:
Expand Platform Command Windows java -Djava.util.logging.config.file=%CXF_HOME%\etc\mylogging.properties demo.hw.client.Client .\wsdl\hello_world.wsdl
UNIX java -Djava.util.logging.config.file=$CXF_HOME/etc/mylogging.properties demo.hw.client.Client ./wsdl/hello_world.wsdl
The SOAP messages are logged to the console.