How do I fix whatever is causing this to flood my logcat: I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false

后端 未结 5 488
野性不改
野性不改 2020-12-29 04:08

I\'m writing an Android app that access the internet. It runs without error, but ever since I upgraded my device (Samsung Galaxy S5) to Android 5.0.1 my logcat is flooded wi

相关标签:
5条回答
  • 2020-12-29 04:31

    Solution:

    Add in your application tag:

    android:usesCleartextTraffic="true"
    

    As follows:

    <application
        ....
        android:usesCleartextTraffic="true"
        ....>
    
    0 讨论(0)
  • 2020-12-29 04:35

    You can use the regex filter to hide the log message flooding your log:

    ^((?!isSBSettingEnabled).)*$
    

    You can also hide more than one offending log by using |. For example

    ^((?!isSBSettingEnabled|OtherLog|OtherLog2|Annoying Messages).)*$
    
    0 讨论(0)
  • 2020-12-29 04:43

    If you are using HttpLoggingInterceptor on the application that runs on a Samsung device, just set the loglevel to the body, it will fix everything. Something like this should work fine:

    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    
    0 讨论(0)
  • 2020-12-29 04:50

    A better solution is offered in Android 7.0 through network security configuration file. How to use it? 1. Add a network security config file under res/xml. 2. Add a domain config and set cleartextTrafficPermitted to “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>
    
    1. Add your network security config to your Android manifest file under application.

      <application
          android:name=".MyApplication"
          android:networkSecurityConfig="@xml/network_security_config">
      

    0 讨论(0)
  • 2020-12-29 04:57

    You are probably using a HttpUrlConnection or a HttpsUrlConnection. Maybe you can find out which class is logging by calling getClass() on the corresponding connection and turn it off with the Logger.getLogger("...").setLevel(Level.OFF);

    See also Enable logging for JDK class programmatically

    0 讨论(0)
提交回复
热议问题