Suman
Suman

Reputation: 4251

How to enable the HTTP logs in Android?

I wrote a simple application and I am getting only those logs, I used Log.i();
I want the core logs (for example framework logs) how the httpclient, httpget, httppost, httprequest and httpresponse logs are sending and receiving data.

Please let me know if there is any procedure.

Upvotes: 3

Views: 5445

Answers (2)

Bao Le
Bao Le

Reputation: 17487

For latest api, using this code

java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST);
java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST);

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug");

and properties:

adb shell setprop log.tag.org.apache.http VERBOSE
adb shell setprop log.tag.org.apache.http.wire VERBOSE
adb shell setprop log.tag.org.apache.http.headers VERBOSE

Upvotes: 3

Ollie C
Ollie C

Reputation: 28509

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

Upvotes: 5

Related Questions