Android adb logcat输出日志显示不全解决方案
            时间:2016-06-02 16:23:45  
            收藏:0  
            阅读:353
        
        
        在终端中使用adb logcat打印服务器json数据,如果返回数据过大超过4000字节(4K)即会截断不显示
原因:logcat在对于message的内存分配大概是4k左右.所以超过的内容都直接被丢弃;
解决方案:切分超过4k的message,使用多个Log.i输出
public static void showLog(String str) {
            str = str.trim();
            int index = 0;
            int maxLength = 4000;
            String finalString;
            while (index < str.length()) {
                if (str.length() <= index + maxLength) {
                    finalString = str.substring(index);
                } else {
                    finalString = str.substring(index, maxLength);
                }
                index += maxLength;
                LogHelper.i("str", finalString.trim());
            }
 }
如果想研究源代码,请简单参照如下:
Logcat工具源代码位于system/core/logcat目录下,只有一个源代码文件logcat.cpp,编译后生成的可执行文件位于out/target/product/generic/system/bin目录下,在模拟机中,可以在/system/bin目录下看到logcat工具。
原文:http://www.cnblogs.com/zgz345/p/5553320.html
            评论(0)
        
        
        