3

I noticed that logcat starts missing logs when printing at a fast pace. I reproduced the error printing different logs very quickly for the same tag, but couldn't find the reason why. The testing loop is this:

    for (int i = 0; i < 500; ++i) {
        Log.i("TestLogging", "AAAAAAAAAAAAAA " + i);
        Log.i("TestLogging", "BBBBBBBBBBBBBB " + i);
        Log.i("TestLogging", "CCCCCCCCCCCCCC " + i);
        Log.i("TestLogging", "DDDDDDDDDDDDDD " + i);
        Log.i("TestLogging", "EEEEEEEEEEEEEE " + i);
        Log.i("TestLogging", "FFFFFFFFFFFFFF " + i);
        Log.i("TestLogging", "GGGGGGGGGGGGGG " + i);
        Log.i("TestLogging", "HHHHHHHHHHHHHH " + i);
    }

The ouput after some interations is this:

2020-03-06 17:19:46.974 22045-22045/? I/TestLogging: CCCCCCCCCCCCCC 428
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: FFFFFFFFFFFFFF 432
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: EEEEEEEEEEEEEE 433
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: DDDDDDDDDDDDDD 438
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: FFFFFFFFFFFFFF 442
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: CCCCCCCCCCCCCC 443
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: GGGGGGGGGGGGGG 444
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: AAAAAAAAAAAAAA 446
2020-03-06 17:19:46.975 22045-22045/? I/TestLogging: HHHHHHHHHHHHHH 446
2020-03-06 17:19:46.976 22045-22045/? I/TestLogging: BBBBBBBBBBBBBB 452
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: BBBBBBBBBBBBBB 467
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: EEEEEEEEEEEEEE 467
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: DDDDDDDDDDDDDD 470
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: HHHHHHHHHHHHHH 475
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: AAAAAAAAAAAAAA 480
2020-03-06 17:19:46.977 22045-22045/? I/TestLogging: BBBBBBBBBBBBBB 480

Anyone knows if there is a solution to this issue?

  • 2
    Welcome to Stack Overflow! You seem to be assuming that log output will always be sequential, but if/when multiple threads are writing to the logs, log entries may appear out of order. Are you sure there's a problem here? – Gabriel Bauman Mar 06 '20 at 18:56
  • 2
    @GabrielBauman that's a for loop, not multiple threads...logs within a thread are ordered, they'd be quite useless if they were not. The OP is quite likely hitting log throttling. There's a limit to how quickly you can log. – Ryan M Mar 06 '20 at 19:11
  • 1
    @GabrielBauman Thank you! I think this is not an issue with threads as logs are clearly missing from the output, not misplaced. – João Pedro Neves Mar 06 '20 at 22:35
  • @RyanMentley I thought about that, but couldn't find anything on doc or any other info about this. Can you point me to where this limit is mentioned? – João Pedro Neves Mar 06 '20 at 22:44
  • 1
    https://stackoverflow.com/questions/34587273/android-logcat-logs-chatty-module-line-expire-message is probably relevant - you're very likely getting these `Chatty` logs – Ryan M Mar 06 '20 at 23:54
  • 1
    @RyanMentley My app is indeed marked as chatty. I tried to whitelist my app with PID, UID and PID/UID but none worked, it continues to collapse my logs – João Pedro Neves Mar 09 '20 at 16:14

0 Answers0