Java apachecxf日志记录
我在使用ApacheCxf框架通过web服务进行服务器-客户机通信时遇到了一些问题。我想将服务器错误记录到外部文件,而不是终端文件。服务器的一段代码Java apachecxf日志记录,java,maven,cxf,Java,Maven,Cxf,我在使用ApacheCxf框架通过web服务进行服务器-客户机通信时遇到了一些问题。我想将服务器错误记录到外部文件,而不是终端文件。服务器的一段代码 server= new JaxwsNotificationBroker("Hello",..); server.setAddress("http://localhost:" + brokerPort + "/wsn/NotificationBroker"); 我试着把它记录下来 server.getInInterceptors().add(new
server= new JaxwsNotificationBroker("Hello",..);
server.setAddress("http://localhost:" + brokerPort + "/wsn/NotificationBroker");
我试着把它记录下来
server.getInInterceptors().add(new LoggingInInterceptor());
server.getOutInterceptors().add(new LoggingOutInterceptor());
但是它给出了错误,类型JaxwsNotificationBroker的getInInterceptors()方法未定义
是否有任何方法记录JaxwsNotificationBroker
的错误
谢谢如果您正在使用spring,请将此添加到spring配置文件中:
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
如果使用log4j进行日志记录,则必须将META-INF/cxf/org.apache.cxf.Logger文件放在类路径上,其中包含“org.apache.cxf.common.logging.Log4jLogger”类名作为单行,否则cxf将使用JavaTM 2平台的核心日志记录功能。出于某种原因,gnodet希望使所有WS-N内容尽可能独立于CXF,并且只依赖于纯JAX-WS内容。因此,像CXF拦截器这样的好方法是不可能的-(
查看代码,目前唯一的选择是编写JaxwsEndpointManager的子类,该子类将调用super.register方法,然后将其强制转换为CXF EndpointImpl,并在其中设置拦截器。这并不理想-(您可以在cxf:bus
<cxf:bus>
<cxf:ininterceptors>
<ref bean="loggingInInterceptor" />
</cxf:ininterceptors>
<cxf:outinterceptors>
<ref bean="logOutInterceptor" />
</cxf:outinterceptors>
</cxf:bus>
<cxf:bus>
<cxf:ininterceptors>
<ref bean="loggingInInterceptor" />
</cxf:ininterceptors>
<cxf:outinterceptors>
<ref bean="logOutInterceptor" />
</cxf:outinterceptors>
</cxf:bus>