You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 59 Next »

 

Configuring logging levels

In the /etc folder of the CXF distribution there is a sample Java SE logging.properties file you can use to configure logging. For example, if you want to change the console logging level from WARNING to FINE, you need to update two properties in this logging.properties file as below:

.level= FINE
java.util.logging.ConsoleHandler.level = FINE

Once this is done, you will need to set the -Djava.util.logging.config.file property to the location of the logging.properties file. As an example, the Ant target below has this property set:

<target name="runClient">
   <java classname="client.WSClient" fork="true">	    	
      <classpath>
         <pathelement location="${build.classes.dir}"/>
         <fileset dir="${env.CXF_HOME}/lib">
            <include name="*.jar"/>
         </fileset>
      </classpath>
      <jvmarg value="-Djava.util.logging.config.file=/usr/myclientapp/logging.properties"/>
   </java>
</target>

Alternatively, for SOAP clients, you can modify the Java-wide logging.properties file in the JDK_HOME/jre/lib folder, or for servlet-hosted web service providers, placing a logging.properties file in the WEB-INF/classes folder (see here for more details.)

Using Log4j Instead of java.util.logging

As noted above, CXF uses the java.util.logging package ("Java SE Logging") by default. But it is possible to switch CXF to instead use Log4J. This is achieved through the use of configuration files. There are two options to bootstrapping CXF logging and each is listed below:

  • Add the following system property to the classpath from which CXF is initialized:
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
  • Add the file META-INF/cxf/org.apache.cxf.Logger to the classpath and make sure it contains the following content:
org.apache.cxf.common.logging.Log4jLogger

Using SLF4J Instead of java.util.logging (since 2.2.8)

As noted above, CXF uses the java.util.logging package by default. But it is possible to switch CXF to instead use SLF4J. This is achieved through the use of configuration files. There are two options to bootstrapping CXF logging and each is listed below:

  • Add the following system property to the classpath from which CXF is initialized:
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger
  • Add the file META-INF/cxf/org.apache.cxf.Logger to the classpath and make sure it contains the following content:
org.apache.cxf.common.logging.Slf4jLogger

Debugging Tools

Eclipse IDE

See this blog entry for information on debugging web services using Eclipse. Note this is primarily for tracing/debugging source code; you will probably still want to use one of the tools below to capture network traffic, view SOAP requests and responses, etc.

NetBeans IDE

NetBeans include a debugger, profiler and an HTTP monitor that can assist in troubleshooting SOA applications.

tcpmon and tcptrace

tcpmon allows you to easily view messages as they go back and forth on the wire. The companion utility tcptrace can be used for analysis of the dump.

WSMonitor

WSMonitor in another option to Tcpmon with slightly more functionality.

NetSniffer

NetSniffer makes it possible to track the network traffic between arbitrary devices within a LAN segment.

Wireshark

Wireshark, a network packet analyzer, is useful for following the routing of SOAP messages. It can also help when you are getting an HTML error message from the server that your CXF client cannot normally process, by allowing you to see the non-SOAP error message. See this blog entry for more information.

SOAP UI

SOAP UI can also be used for debugging. In addition to viewing messages, it allows you send messages and load test your services. It also has plugins for the Eclipse IDE, NetBeans IDE and IntelliJ IDEA.

Other Helpful Tools

WSDL Viewer

WSDL Viewer is a small tool to visualize web-services in a more intuitive way.

SOAP Fault for debugging

This feature is available since CXF 2.3.4

Stack trace in fault details

CXF supports the ability to put server stack trace information into the fault message fault details, if you enable the option of 'faultStackTraceEnabled'. It is useful for debugging if the soap fault message is not defined in the WSDL operation.

<jaxws:endpoint id="server" address="http://localhost:9002/TestMessage" 
   wsdlURL="ship.wsdl"
   endpointName="s:TestSoapEndpoint"
   serviceName="s:TestService"
   xmlns:s="http://test" >
   <jaxws:properties>		
      <entry key="faultStackTraceEnabled" value="true" />
   </jaxws:properties>
</jaxws:endpoint>

Showing the cause exception message

CXF doesn't show the cause exception message in the fault message due to security consideration. However, this could potentially cause some trouble on the client side, as the client will not be able to see what the real cause of the exception is. You can let the CXF server return the fault message with the embedded cause exception message by enabling the option of 'exceptionMessageCauseEnabled' like this:

<jaxws:endpoint id="server" address="http://localhost:9002/TestMessage" 
   wsdlURL="ship.wsdl"
   endpointName="s:TestSoapEndpoint"
   serviceName="s:TestService"
   xmlns:s="http://test" >
   <jaxws:properties>	
      <entry key="exceptionMessageCauseEnabled" value="true" />		
   </jaxws:properties>
</jaxws:endpoint>

 

 

  • No labels