HTTP request logging
penberg opened this issue · comments
As I am debugging a JMX startup hang (#100), I need more visibility into what the JMX proxy is doing internally.
I wanted to trace HTTP requests, but I am unable to get anything out of Jersey, even with the LoggingFeature
capability in Jersey 2.30.1:
diff --git a/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java b/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java
index 8bc7ddc..5b5d86c 100644
--- a/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java
+++ b/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java
@@ -37,6 +37,8 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.logging.LoggingFeature;
+import java.util.logging.Level;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.scylladb.jmx.utils.SnapshotDetailsTabularData;
@@ -54,7 +56,12 @@ public class APIClient {
this.config = config;
this.clientConfig = new ClientConfig();
clientConfig.register(new JacksonJaxbJsonProvider());
- this.client = ClientBuilder.newClient(clientConfig);
+ LoggingFeature feature = new LoggingFeature(logger, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT, 8192);
+ this.client = ClientBuilder
+ .newBuilder()
+ .withConfig(clientConfig)
+ .register(feature)
+ .build();
}
private String getCacheKey(String key, MultivaluedMap<String, String> param, long duration) {
adding sample from Amnon:
"
Example a log.properties file I used myself as an example
you should add to the java command line
-Djava.util.logging.config.file=log.properties
I believe the scylla-jmx passes all -D command line variables to the internal java, so it should work (I've edited the scylla-jmx locally and added it to the java call part so I will not need to remember how to do it).
so it should work by calling:
scylla-jmx -Djava.util.logging.config.file=log.properties
"
log.properties.txt