要启用日志记录的Apache Commons的HttpClient在我用正常的Java应用程序:
System.setProperty(org.apache.commons.logging.Log,org.apache.commons.logging.impl.SimpleLog);
System.setProperty(org.apache.commons.logging.simplelog.showdatetime,真);
System.setProperty(org.apache.commons.logging.simplelog.log.httpclient.wire,调试);
System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient,调试);
不过,在Android上我没有看到日志中LogCat中。
我失去了一些东西?
解决方案下面是一个解决方案(没有挖掘到的细节)
控制台:
亚行外壳setprop log.tag.httpclient.wire.header VERBOSE
亚行外壳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);
测试:
java.util.logging.Logger.getLogger("httpclient.wire.content").log(java.util.logging.Level.CONFIG, HOLA);To enable logging for apache commons HttpClient in normal Java application I used:
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.commons.httpclient", "debug");
But on android I don't see logs in LogCat.
Am I missing some thing?
解决方案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");