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

The question:

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?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

To see the size use -g

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

Method 2

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

Developer Options ScreenShot

Method 3

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.

Method 4

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.

Method 5

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.

Method 6

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.

Method 7

Samsung Galaxy S4 (Android 4.3) logcat size:

  • main: 1 MB
  • system: 512 KB

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment