1

I am using Logcat to debug my app that uses OpenGL. My OpenGL onDraw loop is entered 30 to 60 times per second. I placed 'many' Log.d (around 30) in this loop in order to debug my app (namely to see which part of the code are too time consuming).

My problem is that I see that I don't have all my Log.d in the LogCat. They are randomly ignored on each frame.

This problem seems already known, for example here.

Is there any solution in order to avoid this problem ? Any other log tool ? Any settings to change in Android studio ? Any workaround ?

Thanks !

toto_tata
  • 14,526
  • 27
  • 108
  • 198

3 Answers3

1

There is a lightweight logger framework that you can use that is also capable of logging into a file.

I would recommend doing either logging into a file or reducing your logging. You said you log around 30 times for a single frame. Doing that up to 60 times in a second means 1800 logs a second. So around every half millisecond you log something.

Beside the fact that you overflow the logcat buffer this way in a few seconds, it will not really help you.

I would recommend to define a start and an endpoint for your time measurement and modify it to find the part that is too time consuming. Also only log the measured time, do not rely on the timestamp of the log in the logcat. So don't log "start" and "stop" timestamps, only the real duration.

I also assume that you are calling some functions or do some loops in your onDraw(). These are a good place to start separate measuring. Also consider that logging itself might have an effect on the performance so throwing too much logging into the onDraw() will likely return wrong results.

edit

There is also this answer which might help you too: https://stackoverflow.com/a/35553778/180538

edit2

Your "link" about the issue is 11 years old. It is very likely that this "issue" is already fixed. I do remember that I wrote a file logger once myself and never experienced this issue and I plain logged 10000 lines in a one line for loop...

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
0

In Android Studio, you can filter logcat output. Just right-click the line in the logcat and select "Filter similar". Then fine-tune your filtering rule.

Sorry, I'm on phone, so not sure of exact naming, but it's definitely there. I use it often.

Václav Hodek
  • 638
  • 4
  • 9
0

Solved my problem. Actually, the problem was due to the fact that I had a lot of other logs generated in other parts of my app. I didn't see them as I had a filter in LogCat. Removing the filter allowed me to see all my logs, I saw that I had a lot of logs coming from other threads ; I commented these other logs. Solved my issue :) Thanks for your help !

toto_tata
  • 14,526
  • 27
  • 108
  • 198