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.
To log the messages that are sent between a service and a consumer, and vice versa, complete the following steps:
Add the logging feature your endpoint's configuration as shown in Example 5.11.
Example 5.11. Adding Logging to Endpoint Configuration
<jaxws:endpoint ...> <jaxws:features> <bean class="org.apache.cxf.feature.LoggingFeature"/> </jaxws:features> </jaxws:endpoint>
The example XML shown in Example 5.11 enables the logging of SOAP messages.
Add the logging feature your client's configuration as shown in Example 5.12.
Example 5.12. Adding Logging to Client Configuration
<jaxws:client ...> <jaxws:features> <bean class="org.apache.cxf.feature.LoggingFeature"/> </jaxws:features> </jaxws:client>
The example XML shown in Example 5.12 enables the logging of SOAP messages.
Ensure that the logging.properties file associated with your service is configured to log INFO level messages,
as shown in Example 5.13.
Example 5.13. Setting the Logging Level to INFO
.level= INFO java.util.logging.ConsoleHandler.level = INFO
To see the logging of SOAP messages modify the wsdl_first sample application located in the
directory, as follows:InstallDir/samples/wsdl_first
Add the
jaxws:featureselement shown in Example 5.14 to thecxf.xmlconfiguration file located in the wsdl_first sample's directory:Example 5.14. Endpoint Configuration for Logging SOAP Messages
<jaxws:endpoint name="{http://apache.org/hello_world_soap_http}SoapPort" createdFromAPI="true"> <jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties> <jaxws:features> <bean class="org.apache.cxf.feature.LoggingFeature"/> </jaxws:features> </jaxws:endpoint>
The sample uses the default
logging.propertiesfile, which is located in thedirectory. Make a copy of this file and name itInstallDir/etcmylogging.properties.In the
mylogging.propertiesfile, change the logging levels toINFOby editing the.leveland thejava.util.logging.ConsoleHandler.levelconfiguration properties as follows:.level= INFO java.util.logging.ConsoleHandler.level = INFO
Start the server using the new configuration settings in both the
cxf.xmlfile and themylogging.propertiesfile as follows:Platform Command Windows start java -Djava.util.logging.config.file=%CXF_HOME%\etc\mylogging.properties demo.hw.server.ServerUNIX java -Djava.util.logging.config.file=$CXF_HOME/etc/mylogging.properties demo.hw.server.Server &Start the hello world client using the following command:
Platform Command Windows java -Djava.util.logging.config.file=%CXF_HOME%\etc\mylogging.properties demo.hw.client.Client .\wsdl\hello_world.wsdlUNIX 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.








