にはApache CXFインターセプターとのlog4jを使用して完全な要求と応答をログに記録するLog4jのは<p>は以下の</p> 春に、私は、Apache CXFを使用してSOAP Webサービスの要求と応答をログに記録しようとしています春
私cxf.xmlが
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<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>
</beans>
私です
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
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.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint id="bookShelfService"
implementor="com.test.services.BookShelfServiceImpl" address="/bookshelfservice" />
</beans>
log4j.properties
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\wsimport\\log.txt
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
私org.apache.cxf.Logger
org.apache.cxf.common.logging.Log4jLogger
とweb.xml
bean.xml私はすべてのものの上に行っているが、それでも私は、私は自分のアプリケーションを展開し、サービスを実行するためのSOAPUIを使用するためにTomcatを使用していますヘッダ
と私のサービスの要求と応答のログを取得しておりません。
私はここで間違っていますか?
をお勧めします。
しかし、私は、コードの下に実行していたとき、私は、Eclipseのコンソールに
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(BookShelfService.class); //the service SEI
factory.setAddress("http://localhost:8080/springapp/bookshelfservice");
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
BookShelfService client = (BookShelfService) factory.create();
BookVO reply = client.getBook("b1");
System.out.println("Server said: " + reply.getAuthor());
使用しているインターセプタはCXF 3.2.0で非推奨であることに注意してください:https://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/LoggingInInterceptor.html。それが問題であれば、代わりにorg.apache.cxf.ext.logging.LoggingInInterceptor(およびLoggingOut)を使用してください。 – lpratlong