我正在编写一个访问互联网的Android应用。它运行没有错误,但自从我将我的设备(三星Galaxy S5)升级到Android 5.0.1后,当我的手机运行应用程序时,我的logcat充斥着以下消息:
05-20 16:05:35.514 23322-23440/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:35.514 23322-23440/scave.dvend I/System.out﹕ (HTTPLog)-Static: isShipBuild true
05-20 16:05:35.514 23322-23440/scave.dvend I/System.out﹕ (HTTPLog)-Thread-23345-153023149: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-20 16:05:35.514 23322-23440/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:35.564 23322-23440/scave.dvend I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-20 16:05:36.184 23322-23440/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:37.784 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:37.884 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.034 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.164 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.404 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.544 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.774 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:38.864 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:39.084 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:39.204 23322-23634/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
...
05-20 16:05:46.334 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.364 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.404 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.454 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.514 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.554 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:46.604 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:47.964 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.644 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.674 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.694 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.704 23322-24029/scave.dvend I/System.out﹕ KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-20 16:05:48.754 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.804 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.844 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.874 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.914 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.944 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:48.994 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.564 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.604 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.654 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.714 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.744 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.774 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.824 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.834 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.864 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.904 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.944 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:50.984 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.014 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.044 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.094 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.124 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.144 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.204 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.224 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.254 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.304 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.424 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.504 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.554 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.594 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.624 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.654 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.714 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.744 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:51.774 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.134 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.204 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.324 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.384 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.414 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:53.444 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:54.684 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:54.724 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
05-20 16:05:54.744 23322-24029/scave.dvend I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
这是我的logcat看起来像的极小样本。这甚至意味着什么?有没有办法将“isSBSettingEnabled”设置为true才能让它闭嘴?
答案 0 :(得分:12)
您可以使用正则表达式过滤器隐藏充斥日志的日志消息:
^((?!isSBSettingEnabled).)*$
您还可以使用|
隐藏多个违规日志。例如
^((?!isSBSettingEnabled|OtherLog|OtherLog2|Annoying Messages).)*$
答案 1 :(得分:6)
您可能正在使用HttpUrlConnection
或HttpsUrlConnection
。也许您可以通过在相应的连接上调用getClass()
找出正在记录的类,并使用Logger.getLogger("...").setLevel(Level.OFF);
答案 2 :(得分:1)
如果您在运行于三星设备上的应用程序上使用HttpLoggingInterceptor
,只需将loglevel设置为body,它将修复所有问题。这样的事情应该可以正常工作:
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
答案 3 :(得分:0)
Android 7.0中通过网络安全配置文件提供了更好的解决方案。 如何使用它? 1.在res / xml下添加一个网络安全配置文件。 2.添加域配置,并将cleartextTrafficPermitted设置为“ true”。
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">your_domain.com</domain>
</domain-config>
</network-security-config>
将网络安全配置添加到应用程序下的Android清单文件中。
<application
android:name=".MyApplication"
android:networkSecurityConfig="@xml/network_security_config">
答案 4 :(得分:-1)
解决方案:
添加您的application
标签:
android:usesCleartextTraffic="true"
如下:
<application
....
android:usesCleartextTraffic="true"
....>