How to empty (clear) the logcat buffer in Android [duplicate]

我只是一个虾纸丫 提交于 2019-11-27 10:03:17

问题


This question already has an answer here:

  • How can I erase the old data from logcat? 3 answers

How can I empty (clear) the logcat buffer in Android?

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.


回答1:


adb logcat -c

Logcat options are documented here: http://developer.android.com/tools/help/logcat.html




回答2:


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 device supports

adb logcat -g
adb logcat -b all -g
adb shell logcat -b all -g



回答3:


I give my solution for Mac:

  1. With your device connected to the USB port, open a terminal and go to the adb folder.
  2. Write: ./adb devices
  3. The terminal will show something like this: List of devices attached 36ac5997 device
  4. Take note of the serial number (36ac5997)
  5. Write: ./adb -s 36ac5997 to connect to the device
  6. Write: ./adb logcat

If at any time you want to clear the log, type ./adb logcat -c




回答4:


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)



来源:https://stackoverflow.com/questions/3315389/how-to-empty-clear-the-logcat-buffer-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!