使用Apache CXF将请求/响应记录为XML [英] Logging request/response with Apache CXF as XML

查看:380
本文介绍了使用Apache CXF将请求/响应记录为XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用CXF将请求/响应记录为XML,最好是记录到一个单独的文件中,以便我可以监视应用程序在做什么?

Is it possible to log the request/response as XML using CXF, ideally to a separate file so I can monitor what an application is doing?

推荐答案

将以下内容添加到您的端点和客户端:

Add the following to your endpoints and clients:

<jaxws:features>
    <bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>

这会将所有内容记录到服务器日志中.

This will log everything to the server log.

如果要将它们记录在其他位置,请查看内置CXF LoggingInInterceptor和LoggingOutInterceptor的源代码.您可以按照他们惯用的方式来抓取进/出消息,并随心所欲地处理它们.

If you want to log them elsewhere, then look at the source code of the built-in CXF LoggingInInterceptor and LoggingOutInterceptor. You can follow the pattern they use to grab the messages on their way in/out and do with them what you like.

将您自己的拦截器添加到链中,如下所示:

Add your own interceptors to the chain with something like this:

<jaxws:inInterceptors>
    <ref bean="myLoggingInInterceptor" />
</jaxws:inInterceptors>

这篇关于使用Apache CXF将请求/响应记录为XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆