[英]Apache CXF Logging
I have some problems with my server-client communication via web services with Apache CXF framework
. 我通过
Apache CXF framework
Web服务与我的服务器 - 客户端通信有一些问题。 I want to log the server errors to an external file instead of terminal. 我想将服务器错误记录到外部文件而不是终端。 Piece of code for server;
服务器的代码片;
server= new JaxwsNotificationBroker("Hello",..);
server.setAddress("http://localhost:" + brokerPort + "/wsn/NotificationBroker");
And I tried this for logging; 我试着用它来记录;
server.getInInterceptors().add(new LoggingInInterceptor());
server.getOutInterceptors().add(new LoggingOutInterceptor());
But it gives the error The method getInInterceptors() is undefined for the type JaxwsNotificationBroker
. 但它给出了错误
The method getInInterceptors() is undefined for the type JaxwsNotificationBroker
。
Is there any method to log the errors for JaxwsNotificationBroker
? 是否有任何方法可以记录
JaxwsNotificationBroker
的错误?
Thank you 谢谢
You can add loggingInInterceptor
& logOutInterceptor
inside cxf:bus
您可以在
cxf:bus
添加loggingInInterceptor
和logOutInterceptor
<cxf:bus>
<cxf:ininterceptors>
<ref bean="loggingInInterceptor" />
</cxf:ininterceptors>
<cxf:outinterceptors>
<ref bean="logOutInterceptor" />
</cxf:outinterceptors>
</cxf:bus>
add this to your spring config file, if you are using spring: 如果您使用的是spring,请将其添加到spring配置文件中:
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
don't forget to add cxf namespace as 不要忘记添加cxf名称空间为
xmlns:cxf="http://cxf.apache.org/core"
如果使用log4j进行日志记录,则必须将META-INF / cxf / org.apache.cxf.Logger文件放入类路径中,并将“org.apache.cxf.common.logging.Log4jLogger”类名作为单行添加否则cxf将使用JavaTM 2平台的核心日志记录工具。
For some reason, gnodet wanted to keep all the WS-N stuff as independent from CXF as possible and only rely on pure JAX-WS stuff. 出于某种原因,gnodet希望将所有WS-N内容尽可能独立于CXF,并且只依赖于纯JAX-WS的东西。 Thus, nice methods for things like the CXF interceptors aren't possible.
因此,像CXF拦截器这样的好方法是不可能的。 :-(
:-(
Looking at the code, the only option right now would be to write a subclass of JaxwsEndpointManager that would call the super.register method, then cast it to the CXF EndpointImpl, and set the interceptors on there. 查看代码,现在唯一的选择是编写一个JaxwsEndpointManager的子类,它将调用super.register方法,然后将其转换为CXF EndpointImpl,并在那里设置拦截器。 Not really ideal.
不太理想。 :-(
:-(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.