2011-11-10 38 views
0
@InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor" ) 
@OutInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingOutInterceptor") 

public class SKTWeb implements SKTWebService { 

// method logic goes here 

} 

嗨,在CXF方法實現中添加這兩行後。 我能得到SOAP Requestand響應的鞭子下的tomcat服務器控制檯如何使CXF SOAP請求在日誌文件下打印

看到Tomcat下控制檯打印的SOAP請求的情況下

INFO: Inbound Message 
---------------------------- 
ID: 1 
Address: /Sktweb-33.0/services/SKTWeb 
Encoding: UTF-8 
Content-Type: text/xml; charset=UTF-8 
Headers: {cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[local 
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns4:strategy xmlns:ns 

有誰請告訴我如何能得到這個我的日誌文件中(Log4j的)

目前,這是我的log4j.properties文件

log4j.rootCategory=INFO, A1 

# A1 is a DailyRollingFileAppender 

log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.A1.file=/Haieeee.log 
log4j.appender.A1.datePattern='.'yyyy-MM-dd 
log4j.appender.A1.append=true 
log4j.appender.A1.layout=org.apache.log4j.PatternLayout 
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n 

,也是我有META-INF \ CXF \ org \ apache的\ CXF \ LOGG在Web應用程序中使用Log4jLogger.class。 ,也是我一直

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

裏面的endpoints.xml文件

任何幫助,請

回答

0

基本上你希望你的屬性文件由CXF採摘然後使用這個屬性文件,而不是CXF的。 我在我的CXF應用程序中使用彈簧配置。如果你沒有使用任何Spring配置,那麼你創建一個新的配置並在啓動時使用spring上下文監聽器加載它,然後你可以在你的XML文件中添加下面的代碼。

<bean id="log4jInitialization" 
     class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> 
     <property name="targetClass" value="org.springframework.util.Log4jConfigurer" /> 
     <property name="targetMethod" value="initLogging" /> 
     <property name="arguments"> 
      <list> 
       <value>file:fullpath/filename.properties</value> 
      </list> 
     </property> 
    </bean> 

您也可以在<list> </list>classpath:filename.properties。在Spring框架中實現的日誌記錄將用於記錄所有的請求和響應。您也可以使用相同的日誌記錄實現在您的應用程序中使用。

2

看起來有點混亂。你需要你的應用程序安裝到有一個可定位文件META-INF/cxf/org.apache.cxf.Logger(是的,這些都是點這不是一個.java或.class文件!),它應該具有的內容:

org.apache.cxf.common.logging.Log4jLogger 

我使用完全相同的上述在我的代碼它就像一個魅力。

0

始終用攔截器去...添加SLF4J-log4j12-1.6.1.jar,slf4j-;(部署對我的口味,當流量太大了......我不與消息記錄功能雖然使用它) api-1.6.1.jar和commons-logging-1.1.1.jar。將以下代碼粘貼到您的cxf.xml中...

<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" id="loggingInInterceptor" /> 
    <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" id="logOutInterceptor" /> 
    <cxf:bus> 
     <cxf:inInterceptors> 
      <ref bean="loggingInInterceptor" /> 
     </cxf:inInterceptors> 
     <cxf:outInterceptors> 
      <ref bean="logOutInterceptor" /> 
     </cxf:outInterceptors> 
    </cxf:bus>