How to Enable Logging for Apache Commons Httpclient on Android

How to enable logging for apache commons HttpClient on Android

Here is a solution (without digging into details)

Console:

adb shell setprop log.tag.httpclient.wire.header VERBOSE
adb shell setprop log.tag.httpclient.wire.content VERBOSE

Code:

java.util.logging.Logger.getLogger("httpclient.wire.header").setLevel(java.util.logging.Level.FINEST);
java.util.logging.Logger.getLogger("httpclient.wire.content").setLevel(java.util.logging.Level.FINEST);

Test:

java.util.logging.Logger.getLogger("httpclient.wire.content").log(java.util.logging.Level.CONFIG, "hola");

How to enable the HTTP logs in Android?

Here, try this:
https://gist.github.com/cf23c4e184228a132390

how to track http packets on android in java

If you're using Apache HttpClient you can turn on logging, see "How to enable logging for apache commons HttpClient on Android". The options for logging are very flexible.

But Google's energy is going into HttpURLConnection (see "Android Developer's Blog: Android's HTTP Clients"), perhaps somebody else can suggestion good ways to turn on logging there. There's one idea at "HTTP Get Using Android HttpURLConnection" though that particular example would disrupt your service.

Then there's always WireShark.

commons-logging defines classes that conflict with classes now provided by Android after Android Studio Update

Add to build.gradle located in app module

configurations {
all {
exclude module: 'httpclient'
}
}

commons-validator and error commons-logging defines classes that conflict with classes now provided by Android

The problem is with commons-logging. So it must be excluded.
Add the following code in app/build.gradle. It should work.

configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}


Related Topics



Leave a reply



Submit