您的位置:首页 > 移动开发 > Android开发

Android studio打印log显示不全

2017-10-20 10:15 2679 查看

问题:

系统对log长度有限制,如果打印的log过长,比如接口响应结果过大,将会导致Logcat控台数据显示不全。

解决办法:

我们可以分段打印:

4000个字符打印一次。

if (response.length() > 4000) {
for (int i = 0; i < response.length(); i += 4000) {
if (i + 4000 < response.length())
Log.e("333", "response第一段log===" + response.substring(i, i + 4000));
else {
Log.e("333", "response第二段log===" + response.substring(i, response.length()));
}
}
} else {
Log.e("333", "充值记录查询response===" + response);
}


参考:

Android 终于知道Log显示不全的原因了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: