Home » Android » android – What is the size limit for Logcat and how to change its capacity?

android – What is the size limit for Logcat and how to change its capacity?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I believe Logcat is a circular store and I wonder what the limit is before it overwrites.

Presumably this means that its time range will vary according to usage.

Is there any way to expand its capacity?

How to&Answers:

To see the size use -g

$ adb logcat -g
ring buffer is 64Kb (63Kb consumed), max entry is 4096b, max payload is 4076b

Answer:

Since Android 5.0, Developer Options shows/allows increasing the size of ring buffer.

Developer Options ScreenShot

Answer:

As already mentioned, you can see the size of the circular buffer with logcat -g. On my Galaxy Nexus, it’s 256 KB:

[email protected]:/ $ logcat -g
/dev/log/main: ring buffer is 256Kb (255Kb consumed), max entry is 4096b, max payload is 4076b
/dev/log/system: ring buffer is 256Kb (0Kb consumed), max entry is 4096b, max payload is 4076b

If you need to save a continuous log longer than that, you can just open a new adb shell and type

logcat -f myfile.log

This command redirects log entries to the file myfile.log on an ongoing basis, and won’t return until you hit ctrl-c to stop it. Now go back to your original adb shell and type the command you wanted to log, and all its output (more than 256 KB in my case) will get saved to myfile.log.

Answer:

Here’s how to change the log ring buffer’s capacity on some versions of Android:

adb logcat -G <size>: Set the size of the log ring buffer. Can add K or M at the end to indicate kilobytes or megabytes.

(Source: logcat documentation)

However, it doesn’t say at what version of Android this option became available. I see that on my Android 4.2.2 device it’s not a recognized option.

Answer:

Buffer size is determined by the kernel, found in */drivers/staging/android/logger.c

Which buffers are used and the size has changed with Android Versions. Android 3.0 and newer also have a system buffer, and all four are 256kb. You have to recompile the kernel to change it.

Answer:

Samsung Galaxy S4 (Android 4.3) logcat size:

  • main: 1 MB
  • system: 512 KB

Answer:

If you need to change the value by the android shell in a way that survives a reboot, you can use the property persist.logd.size like this:

setprop persist.logd.size 16M

You probably need to reboot for the setting to take effect.
This is the same property that is changed by the developer settings.