41

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?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
ron
  • 5,219
  • 8
  • 39
  • 44
  • 1
    what do you mean with the capacity ? you mean the number of lines that logcat can display , or the length of one line ?? – Houcine Jun 12 '11 at 11:00

7 Answers7

52

To see the size use -g

$ adb logcat -g
ring buffer is 64Kb (63Kb consumed), max entry is 4096b, max payload is 4076b
FeatureCreep
  • 1,784
  • 1
  • 19
  • 23
  • 1
    It is important to note that LogCat is very much device dependent. The size and also the handling of bad character differs between different handsets. – Janusz Jul 22 '11 at 10:04
  • @Janusz is there any source of info regarding the differences?@ – ron Jul 22 '11 at 21:48
  • 1
    To expand, logcat's default buffers are /dev/log/main and /dev/log/system. You can check the other two by using -b radio and -b events – cde Jan 12 '14 at 09:55
  • 2
    what is max entry and max payload? – Lv99Zubat Jun 14 '16 at 21:21
  • 5
    @BrettG, I've tested log output of a string in length of `5000`, and the outputted log message was in the length of `4076`, so according to my test result, I can say that - `max payload` number is **maximum log message length**. All characters after `4076` index, will be ignored. – Eido95 Nov 14 '17 at 18:33
49

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

Developer Options ScreenShot

Robert
  • 39,162
  • 17
  • 99
  • 152
Shubham Chaudhary
  • 47,722
  • 9
  • 78
  • 80
8

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

shell@android:/ $ 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.

Wade Walker
  • 504
  • 6
  • 7
  • The log to file works, if you are looking for something new. Will not help for previously lost information, like from boot. – cde Jan 12 '14 at 09:55
7

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.

LarsH
  • 27,481
  • 8
  • 94
  • 152
  • Downvoter, can you suggest a way to improve the answer? The question asked for a way to change the capacity of the log ring buffer, and this answer gives information answering that question that wasn't in other answers. – LarsH Nov 17 '17 at 01:33
  • Most likely added in 5.0 as per shubham answer in 2015. – cde Mar 29 '18 at 14:36
  • 1
    Assuming the dev option setting that Shubham shows was added at the same time as this `logcat -G` command, it had to be no later than 5.0 but later than 4.2.2. – LarsH Mar 29 '18 at 14:38
4

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.

ChristophK
  • 3,157
  • 2
  • 25
  • 29
2

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.

cde
  • 317
  • 1
  • 18
  • What is the location of log file? And how to access logcat file? – Innocent Mar 29 '18 at 13:37
  • 1
    There is none. It's a memory buffer. The log is not saved to a file, as that would strain the flash storage on a typical android device. – cde Mar 29 '18 at 14:35
1

Samsung Galaxy S4 (Android 4.3) logcat size:

  • main: 1 MB
  • system: 512 KB
Igor Gorjanc
  • 535
  • 4
  • 17