如何在 Android 中更改 logcat 缓冲区的大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12397780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:32:56  来源:igfitidea点击:

How to change size of logcat buffer in Android?

android

提问by zer0stimulus

I noticed that the size of the logcat buffer varies on different devices. Assuming I have root permissions on my device, is there a way to change the buffer size of the main buffer at runtime? If not, then assuming I can rebuild the Android image, how do I change it at compile time? I'm looking to enlarge it for diagnostic purposes.

我注意到 logcat 缓冲区的大小在不同的设备上有所不同。假设我在我的设备上拥有 root 权限,有没有办法在运行时更改主缓冲区的缓冲区大小?如果没有,那么假设我可以重建 Android 映像,我如何在编译时更改它?我希望将其放大以用于诊断目的。

采纳答案by Mickey Tin

According to the newsgroup Android Developers, logcat buffer size:

根据新闻组Android Developerslogcat 缓冲区大小

The log buffers on the device are 64 KB. The timestamp, process ID, and log level are stored in a compact format, so you may actually get more than 64 KB of formatted data out of logcat -d -v <mode>.

设备上的日志缓冲区为 64 KB。时间戳、进程 ID 和日志级别以紧凑格式存储,因此您实际上可能从logcat -d -v <mode>.

回答by Mickey Tin

Set the size of the log ring buffer

设置日志环形缓冲区的大小

adb logcat -G <size> 

Append K or M to indicate kilobytes or megabytes

附加 K 或 M 以指示千字节或兆字节

Example: adb logcat -G 512K

例子: adb logcat -G 512K

回答by Sazzad Hissain Khan

See current buffer size

查看当前缓冲区大小

adb logcat -g

Set all type buffer size (main, system, crash)

设置所有类型缓冲区大小(主、系统、崩溃)

adb logcat -G 16M # 16M can be replace by (128K ~ 16M)

Set specific type buffer size (main, system, crash)

设置特定类型的缓冲区大小(主、系统、崩溃)

adb logcat -b system -G 8M # system can be replaced with 'main' or 'crash'

回答by pna

No, as per hereit seems that the log buffers on the device are 64 KB. The timestamp, process ID, and log level are stored in a compact format, so you may actually get more than 64 KB of formatted data out of logcat -d -v <mode>.

不,按照这里,设备上的日志缓冲区似乎是 64 KB。时间戳、进程 ID 和日志级别以紧凑格式存储,因此您实际上可能从logcat -d -v <mode>.

See also Stack Overflow question What is the size limit for Logcat?.

另请参阅堆栈溢出问题Logcat 的大小限制是多少?.

Anyway, for saving logs elsewhere, you have Reading and Writing Logs. That maybe could help you.

无论如何,为了将日志保存在别处,您可以使用Read and Writing Logs。那也许可以帮助你。

回答by cde

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

缓冲区大小由内核决定,可在 */drivers/staging/android/logger.c 中找到。

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

使用哪些缓冲区以及大小随 Android 版本而变化。Android 3.0(Honeycomb) 及更新版本也有系统缓冲区,四个都是 256 KB。您必须重新编译内核才能更改它。

回答by chaitanya

You can increase the value of idea.cycle.buffer.size=1024 in property file android-studio\bin\idea.properties. This worked for me.

您可以在属性文件android-studio\bin\idea.properties 中增加idea.cycle.buffer.size=1024 的值。这对我有用。

回答by ViliusK

To set logcat buffer to 16Mb for a specific Android device through adb, I used:

要通过 adb 将特定 Android 设备的 logcat 缓冲区设置为 16Mb,我使用了:

adb -s 2615a1d4e3174a6e logcat -G 16M

adb -s 2615a1d4e3174a6e logcat -G 16M

But you can use just:

但你可以只使用:

adb logcat -G 16M

adb logcat -G 16M

Or set previous buffer size with:

或设置以前的缓冲区大小:

adb logcat -G 256K

adb logcat -G 256K