2
这花了我很长时间才弄清楚。我在问这个问题,所以我可以为其他人回答:如何从CXF Rest客户端登录?
如何从CXF Rest Client获得有用的日志记录信息? EG:网址,参数,有效载荷,响应等。
注意:此问题已存在,但它询问CXF和Resteasy。我只想要答案CXF:Logging in CXF and RestEasy clients
这花了我很长时间才弄清楚。我在问这个问题,所以我可以为其他人回答:如何从CXF Rest客户端登录?
如何从CXF Rest Client获得有用的日志记录信息? EG:网址,参数,有效载荷,响应等。
注意:此问题已存在,但它询问CXF和Resteasy。我只想要答案CXF:Logging in CXF and RestEasy clients
这里是你如何使用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());