您如何从CXF Rest Client获取日志? [英] How do you get logging from the CXF Rest Client?

查看:145
本文介绍了您如何从CXF Rest Client获取日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这花了我很长时间才能弄清楚.我在问这个问题,所以我可以为其他人回答:

This took me quite a long time to figure out. I'm asking this question so I can answer it for others:

您如何从CXF Rest Client获得有用的日志记录信息? EG:网址,参数,有效负载,响应等.

How do you get useful logging info from the CXF Rest Client? EG: The url, params, payload, response, etc.

注意:该问题已经存在,但正在询问CXF和Resteasy.我只想要CXF的答案:登录CXF和RestEasy客户端

Note: This question already exists but it's asking about CXF and Resteasy. I only want the answer for CXF: Logging in CXF and RestEasy clients

推荐答案

使用CXF的方法如下:

Here's how you do it with CXF:

import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxrs.client.ClientConfiguration;
import org.apache.cxf.jaxrs.client.WebClient;
import org.json.JSONException;
import org.json.JSONObject;
...
    WebClient client = WebClient.create(endPoint, providers).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON);
    ClientConfiguration config = WebClient.getConfig(client);
    config.getInInterceptors().add(new LoggingInInterceptor());
    config.getOutInterceptors().add(new LoggingOutInterceptor());

这篇关于您如何从CXF Rest Client获取日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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