You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中Log.i()无法打印for循环内全部日志的问题求助

Android Logcat日志丢失:循环打印日志时部分条目被跳过

排查问题时需要查看for循环的所有列表项,但发现Logcat日志存在被跳过的情况,以下是测试细节:

  1. MainActivity按钮点击事件中日志截断
    在按钮点击事件里循环打印1000条日志,但日志只输出到495就停止了:
btnSetting.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (BuildConfig.DEBUG) {
            //testing logging
            for (int n=0; n<1000; n++)
            {
                Log.i(TAG, "Testing Log.i  "+n + "/"+1000);
            }
        }
        /*
        Intent intent = new Intent(MainActivity.this, ConfigActivity.class);

        startActivity(intent);*/
    }
});

日志输出片段:

...
2023-12-31 06:52:52.127  1826-1826  [dbg]MainActivity I  Testing Log.i  493/1000
2023-12-31 06:52:52.127  1826-1826  [dbg]MainActivity I  Testing Log.i  494/1000
2023-12-31 06:52:52.127  1826-1826  [dbg]MainActivity I  Testing Log.i  495/1000
  1. 子页面finish()前日志随机丢失
    在子页面按钮点击事件中,调用finish()返回MainActivity前打印1000条日志,出现随机条目被跳过的情况:
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  0/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  1/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  2/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  5/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  23/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  26/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  28/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  29/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  30/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  35/1000
2023-12-31 06:46:23.811 29705-29705 [dbg]CreatePattern  I  Testing Log.i  37/1000
...

有没有人遇到过同样的问题?

内容的提问来源于stack exchange,提问作者runningdog

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 04:27:08