如何清空(清除)Android 中的 logcat 缓冲区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3315389/
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
How to empty (clear) the logcat buffer in Android
提问by kaskelotti
How can I empty (clear) the logcat buffer in Android?
如何清空(清除)Android 中的 logcat 缓冲区?
I use adb logcat from command line and pipe the output to a file, since the DDMS has a very limited buffer. At the moment, when I restart my app (after fixing bugs etc) the logcat buffer has data from the previous launch as well. Even uninstalling the app does not clear the buffer. The only way I've found so far to clear the buffer, is reboot. This is effective, but would like to know if there's an easier way.
我从命令行使用 adb logcat 并将输出通过管道传输到文件,因为 DDMS 的缓冲区非常有限。目前,当我重新启动我的应用程序时(在修复错误等之后),logcat 缓冲区也包含上次启动的数据。即使卸载应用程序也不会清除缓冲区。到目前为止,我发现清除缓冲区的唯一方法是重新启动。这是有效的,但想知道是否有更简单的方法。
回答by Michael Burr
adb logcat -c
Logcat options are documented here: http://developer.android.com/tools/help/logcat.html
Logcat 选项记录在此处:http: //developer.android.com/tools/help/logcat.html
回答by Lava Sangeetham
The following command will clear only non-rooted buffers (main, system ..etc).
以下命令将仅清除非根缓冲区(主、系统 .. 等)。
adb logcat -c
If you want to clear all the buffers (like radio, kernel..etc), Please use the following commands
如果要清除所有缓冲区(如收音机、内核等),请使用以下命令
adb root
adb logcat -b all -c
or
或者
adb root
adb shell logcat -b all -c
Use the following commands to know the list of buffers that device supports
使用以下命令了解设备支持的缓冲区列表
adb logcat -g
adb logcat -b all -g
adb shell logcat -b all -g
回答by Macario Polo Usaola
I give my solution for Mac:
我给出了我的 Mac 解决方案:
- With your device connected to the USB port, open a terminal and go to the adb folder.
- Write: ./adb devices
- The terminal will show something like this: List of devices attached 36ac5997 device
- Take note of the serial number (36ac5997)
- Write: ./adb -s 36ac5997 to connect to the device
- Write: ./adb logcat
- 将您的设备连接到 USB 端口,打开终端并转到 adb 文件夹。
- 写入:./adb devices
- 终端将显示如下内容:List of devices connected 36ac5997 device
- 记下序列号 (36ac5997)
- 写入:./adb -s 36ac5997 连接设备
- 写:./adb logcat
If at any time you want to clear the log, type ./adb logcat -c
如果您想随时清除日志,请键入 ./adb logcat -c
回答by ColossalChris
For anyone coming to this question wondering how to do this in Eclipse, You can remove the displayed text from the logCat using the button provided (often has a red X on the icon)
对于想知道如何在 Eclipse 中执行此操作的任何人,您可以使用提供的按钮从 logCat 中删除显示的文本(通常在图标上有一个红色的 X)