如何在Android上为Apache Commons HttpClient启用日志记录

为了在普通的Java应用程序中启用apache commons HttpClient的日志记录,我使用了:


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");

但是在android上,我在LogCat中看不到日志。


我错过了什么吗?


幕布斯7119047
浏览 552回答 3
3回答

子衿沉夜

忽略我之前的评论。我在org.apache.http日志记录页面上找到了解决方案。您最初的答案是指httpclient-3.x日志记录,而最新版本的工作代码来自http-components日志记录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");和属性:adb shell setprop log.tag.org.apache.http VERBOSEadb shell setprop log.tag.org.apache.http.wire VERBOSEadb shell setprop log.tag.org.apache.http.headers VERBOSE区别在于日志记录标记名称。

慕尼黑的夜晚无繁华

这是一个解决方案(无需深入研究)安慰:adb shell setprop log.tag.httpclient.wire.header VERBOSEadb shell setprop log.tag.httpclient.wire.content VERBOSE码: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");
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android