当前位置: 首页 > 知识库问答 >
问题:

如何使CXF日志记录功能与SOAP消息一起工作?

翟兴邦
2023-03-14

我已经为CXF设置了日志记录。它正在使用log4j成功地进行日志记录。作为测试,我修改了log4j中的设置。属性,其中根记录器设置为“信息”。

添加log4j.logger.org.apache.cxf=DEBUG, C会导致CXF日志记录出现在日志文件中。但是,SOAP消息在到达服务器时不会被记录。我已经按照指南的要求设置了cxf.xml。文件如下所示:

<beans xmlns="http://www.springframework.org/schema/beans" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://cxf.apache.org/core 
  http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <cxf:bus>
      <cxf:features>
        <cxf:logging />
      </cxf:features>
    </cxf:bus>
</beans>

此文件打包在中时。war,位于WEB-INF/classes/cxf中。xml。根据我的阅读,这就是让CXF开始记录入站和出站消息所需的全部内容。

我有:

>

log4j.logger.org.apache.cxf.interceptor.LoggingInInterceptor=DEBUG, C
log4j.logger.org.apache.cxf.interceptor.LoggingOutInterceptor=DEBUG, C

然而,原始肥皂消息拒绝被记录。我做错了什么?

编辑:添加网站。xml和applicationContext。请求的xml

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:applicationContext.xml</param-value>
  </context-param>

  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <servlet>
      <servlet-name>cxf</servlet-name>
      <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
      <servlet-name>cxf</servlet-name>
      <url-pattern>/*</url-pattern>
  </servlet-mapping>

  <session-config>
      <session-timeout>60</session-timeout>
  </session-config>
</web-app>

应用程序上下文。xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:soap="http://cxf.apache.org/bindings/soap"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/jee
     http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-2.5.xsd
     http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"
   default-dependency-check="none" default-lazy-init="false">

<!-- Load the needed resources that are present in the cxf* jars -->
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

<!--Endpoint Info is below here -->
</beans>

共有1个答案

华誉
2023-03-14

您是否尝试将其添加到WEB-INF/cxf servlet中。xml?以下配置用于记录服务器端消息。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:cxf="http://cxf.apache.org/core" 
    xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans.xsd
     http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
     http://cxf.apache.org/core 
     http://cxf.apache.org/schemas/core.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <cxf:bus>
        <cxf:features>
            <cxf:logging />
        </cxf:features>
    </cxf:bus>  

    <jaxws:endpoint ... />        
</beans>

这假设您是根据CXF使用Spring编写服务来声明服务的。

至于cxf。xml,我相信这可能是用于客户端配置的,尽管我找不到任何支持文档。

 类似资料:
  • 问题内容: 我正在使用Python日志记录,由于某种原因,我的所有消息都出现两次。 我有一个配置日志记录的模块: 稍后,我调用此方法来配置日志记录: 然后,在buy_ham模块中,我将调用: 由于某种原因,所有消息都出现两次。我注释掉其中一个流处理程序,还是一样。有点奇怪,不确定为什么会这样…大声笑。假设我错过了一些显而易见的事情。 干杯,维克多 问题答案: 您正在调用两次(也许使用的方法):将返

  • 正如AWS文件所示: 现在我做了: 第一段代码打印在Cloud Watch控制台中,但第二段没有。 我没有看到任何区别,因为这两个代码段使用的是根记录器。

  • 我希望能够为每个日志消息执行一个方法,允许我在日志记录之前动态修改该消息。我知道有一些过滤器允许我指示是否应该记录消息,但我不想阻止记录消息,我只想在记录之前对其进行修改。我该怎么做呢? 注意:我问了这个关于log4j2的问题,但我也对其他流行Java日志框架持开放态度。

  • 互联网上有许多帖子建议如何从logback迁移到log4j2进行Spring引导日志记录。 参考这个sof post-Spring Boot日志与log4j2-我已经配置我的项目使用log4j2。然后我添加了一些基本的log4j2.xml和log4j2.properties文件来测试。 但是在这些更改之后,我的项目无法进行任何日志记录。有人能帮我找出毛病吗? 项目代码可在github-https:

  • 问题内容: 当我们从本地群集运行时,我想关闭默认提供的日志记录功能。当前,它在控制台上记录了很多信息。 以下是日志示例: 在阅读了许多文档之后,我得到了以下代码,我可以从类中关闭日志记录。 输出(正确): 但是我需要更改Storm / zookeper等的日志记录配置。 有人可以帮忙吗? 更新 :以下是我尝试过的代码,但是它不起作用。我尝试使用0.7.1、0.8.2和0.9.0-wip *版本 问

  • 我正在使用apache CXF(Spring启动)来开发我的肥皂服务器。在这里,我需要在我的肥皂故障拦截器中记录故障消息,就像在任何肥皂客户端中显示的那样(例如:肥皂UI)。我如何在我的故障拦截器中记录相同的输出?现在它只是显示异常详细信息 输入 输出(在肥皂客户端中显示) UserNotfindException是代码中抛出的自定义异常 我的定制拦截器代码