13

When I connect to a device or an emulator using adb, I can clear logcat using adb logcat -c. The issue I am facing is that I often get the following message:

failed to clear the 'main' log

AFAIK, 'main' is a non-rooted buffer which means that I should be able to clear it without root. What can then be the reason for this message?

vatbub
  • 2,713
  • 18
  • 41

3 Answers3

8

You might have your Android Studio opened, please close it and run again , it should able to clear the logs.

user1421092
  • 3,123
  • 2
  • 14
  • 8
7

use

adb logcat -b all -c 

it will clear all buffers. sometime adb logcat -c will not work because of many process using it like android studio.

Parag Jain
  • 612
  • 2
  • 14
  • 31
  • 1
    This shows me the same error but with 'events' log: ``logcat: failed to clear the 'events' log.`` – Marc Sances Oct 15 '21 at 06:40
  • @MarcSances there is possibility that by using -b option also we will not be able to clear logcat . That can be because of some lock condition by some process. may be if you can try multiple time same command. Still if it won't work in that case if it is possible then disconnect adb and connect it again. – Parag Jain Oct 16 '21 at 05:40
-1

Logcat messages are stored in buffer, you can try,

adb logcat -c

Clear (flush) the selected buffers and exit. The default buffer set is main, system and crash. To clear all of the buffers, use -b all -c.

source: logcat doc

For more logcat usage, check How do I get the logfile from an Android device?

Zhaolong Zhong
  • 300
  • 3
  • 6