java - Apache CXF 日志记录

标签 java maven cxf

我在使用 Apache CXF 框架 通过 Web 服务进行服务器与客户端通信时遇到一些问题。我想将服务器错误记录到外部文件而不是终端。服务器代码段;

server= new JaxwsNotificationBroker("Hello",..);
server.setAddress("http://localhost:" + brokerPort + "/wsn/NotificationBroker");

我尝试用这个来记录;

server.getInInterceptors().add(new LoggingInInterceptor());
server.getOutInterceptors().add(new LoggingOutInterceptor());

但它给出了错误The method getInInterceptors() is undefined for the type JaxwsNotificationBroker

是否有任何方法可以记录 JaxwsNotificationBroker 的错误?

谢谢

最佳答案

您可以在cxf:bus内添加loggingInInterceptorlogOutInterceptor

<cxf:bus>
    <cxf:ininterceptors>
      <ref bean="loggingInInterceptor" />
    </cxf:ininterceptors>
    <cxf:outinterceptors>
      <ref bean="logOutInterceptor" />
    </cxf:outinterceptors>
  </cxf:bus>

关于java - Apache CXF 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11431081/

相关文章:

Java - 如何获取交错迭代器/集合

java - 通过字段 'service' : No qualifying bean of type 表示的未满足的依赖关系

java - 关于 JPA TABLE_PER_CLASS 和子实体 id

maven - 排除隐藏文件夹以生成原型(prototype)

java - 如何使用 log4j2 记录 CXF web 服务请求?

Java:在 Windows 和 Linux 上处理注销或关机

java - Maven 程序集 : unresolved compilation error

java - 如何在 Intellij 中将 "java"文件夹创建到 Maven webapp 项目中?

java - 如何在CXF拦截器中获取HTTP响应代码?

http - 是否可以在没有 tomcat 的情况下使用 cxf 提供 http 服务