170

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.

Antonio
  • 19,451
  • 13
  • 99
  • 197
kaskelotti
  • 4,709
  • 9
  • 45
  • 72

4 Answers4

332
adb logcat -c

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

jensck
  • 154
  • 1
  • 11
Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • 2
    Thanks. That is exactly what I was looking for. I was trying find the options from the command line help. – kaskelotti Jul 23 '10 at 06:25
  • @ J Andy Hi, I am new to android. How did you use in program? Would you please tell me? I am also looking for this but could not find a way how to use in program? Thanks. –  Jun 26 '11 at 07:32
  • See also `adb logcat --help`. – i_am_jorf Aug 05 '11 at 17:19
  • 1
    @AndroidVogue: this is done from the terminal on your development machine. I don't think there's any reason to clear the log within a program. – aksommerville Sep 21 '11 at 17:09
  • You can empty the other buffers likewise. E.g., `adb logcat -c -b radio` – Dheeraj Vepakomma Sep 05 '12 at 07:11
  • 1
    Wish they would add that to the Eclipse logcat window - the clear logcat there just clears the current display. – Tom Jun 25 '13 at 19:56
  • if `adb` can't be found look in `C:\Users\\AppData\Local\Android\android-sdk\platform-tools` Now is there a way to run this prior to Debugging ? – wal Sep 30 '15 at 07:51
  • is that OS related? on a macbook it worked, but on my windows (using a mingw64 bash terminal) i get: `failed to clear the 'main' log` – ThunderWiring Oct 07 '17 at 11:13
15

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
Lava Sangeetham
  • 2,943
  • 4
  • 38
  • 54
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

2

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)

Chris Klingler
  • 5,258
  • 2
  • 37
  • 43