|
Debugging has been edited by Bruce Snyder (Mar 06, 2008). Content:Logging MessagesCXF uses Java SE Logging Configuration files are probably best. They offer two benefits over programmatic configuration:
Enabling message logging through configuration files is shown here For programmatic configuration, the logging interceptors can be added to your service endpoint as follows: import javax.xml.ws.Endpoint; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.jaxws.EndpointImpl; Object implementor = new GreeterImpl(); EndpointImpl ep = (EndpointImpl) Endpoint.publish("http://localhost/service", implementor); ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); For web services running on CXFServlet, the below annotations can be used on either the SEI or the SEI implementation class. If placed on the SEI, they activate logging both for client and server; if on the SEI implementation class, they are relevant just for server-side logging. import org.apache.cxf.feature.Features; @javax.jws.WebService(portName = "MyWebServicePort", serviceName = "MyWebService", ...) @Features(features = "org.apache.cxf.feature.LoggingFeature") public class MyWebServicePortTypeImpl implements MyWebServicePortType { or (equivalent) import org.apache.cxf.interceptor.InInterceptors; import org.apache.cxf.interceptor.OutInterceptors; @javax.jws.WebService(portName = "WebServicePort", serviceName = "WebServiceService", ...) @InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor") @OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor") public class WebServicePortTypeImpl implements WebServicePortType { For programmatic client-side logging, the following code snippet can be used as an example: import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; public class WSClient { public static void main (String[] args) { MyService ws = new MyService(); MyPortType port = ws.getPort(); Client client = ClientProxy.getClient(port); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); // make WS calls... Configure 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> Using Log4j Instead of java.util.loggingAs noted above, CXF uses the java.util.logging package by default. But it is possible to switch CXF to instead use Log4J
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
org.apache.cxf.common.logging.Log4jLogger Debugging ToolsEclipse IDESee this blog entry TcpmonTCPMon WSMonitorWSMonitor SOAP UISOAP UI WiresharkWireshark |
Unsubscribe or edit your notifications preferences
