1.代码方式
public final class Server {
public static void main(String args[]) throws Exception {
CourseBuilderImpl implementor = new CourseBuilderImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setAddress("http://localhost:9000/CourseBuilder");
svrFactory.setServiceBean(implementor);
svrFactory.getFeatures().add(new LoggingFeature());
svrFactory.create();
}
}
限制大小
public final class Server {
public static void main(String args[]) throws Exception {
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
...
// This will only log upto 1K or 1024 characters
svrFactory.getFeatures().add(new LoggingFeature(1024));
...
}
}
指定输出文件
public final class Server {
public static void main(String args[]) throws Exception {
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
...
svrFactory.getFeatures().add(
new LoggingFeature("<stdout>", "file://home/myLog.txt"));
...
}
}
2.注解方式
@WebService
@Features(features = "org.apache.cxf.feature.LoggingFeature")
public class CourseBuilderImpl implements CourseBuilder {
...
3.Spring集成方式
<beans>
...
<jaxws:endpoint
id="courseBuilder"
implementor="demo.cxf.logging.CourseBuilderImpl"
address="/CourseBuilder" >
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
</jaxws:endpoint>
</beans>