[英]How to log Jersey client request when using Apache client
I'm using jersey apache connector so that my jersey client uses apache http client: I'm using jersey apache connector so that my jersey client uses apache http client:
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
</dependency>
I initialize the client this way:我以这种方式初始化客户端:
ClientConfig conf = new ClientConfig().connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newClient(conf);
Now I expect to be able to log http traffic by just adding this in my logback-test.xml:现在我希望能够通过在我的 logback-test.xml 中添加这个来记录 http 流量:
<logger name="org.apache.http.wire" level="DEBUG" />
But it's not logging anything, am I missing something?但它没有记录任何东西,我错过了什么吗?
UPDATE: Ok I may have missed that Jersey is using java.util.logging while my app is using slf4j + logback.更新:好的,我可能错过了 Jersey 正在使用 java.util.logging 而我的应用程序正在使用 slf4j + logback。 So I've added a jul-to-slf4j bridge with corresponding conf, but still no log.所以我添加了一个带有相应conf的jul-to-slf4j桥,但仍然没有日志。
Well, 9 views, Stackoverflow is not what it used to be...嗯,9 次浏览,Stackoverflow 已经不是以前的样子了……
So the answer is: the logging system at apache http client level is disabled when it's used with jersey.所以答案是:apache http 客户端级别的日志记录系统在与 jersey 一起使用时被禁用。 You can activate logs for jersey, but it's not like all others libraries, u have to explicitely register a "LoggingFeature" for it to start to log with jul, then the bridge works.您可以激活 jersey 的日志,但它与所有其他库不同,您必须明确注册一个“LoggingFeature”才能开始使用 jul 进行日志记录,然后桥接工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.