简体   繁体   中英

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:

<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:

<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. So I've added a jul-to-slf4j bridge with corresponding conf, but still no log.

Well, 9 views, Stackoverflow is not what it used to be...

So the answer is: the logging system at apache http client level is disabled when it's used with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM