Search code examples
androidloggingadblogcatandroid-logcat

Android: What is the impact of adb logcat -c?


In my application every time i want to read fresh log cat logs, to do this, I use below mentioned adb commands.

  1. adb logcat -d -v time *:E

    -->This will give the latest logs.

  2. adb logcat -c

    --> This will clear all logs and exist

If i run 1st command again, i will get only current logs(as old logs deleted by 2nd command)

This i will doing this programatically (as my app is signed) through out the day.

So, If I use command "adb logcat -c" will it permanently deletes all logs ?, If any user, they want access the old logs for some debugging purpose, how would they can access the old logs ? Will they can able to access ?

Suggest me, if I am doing something wrong here.

Thanks in Advance!


Solution

  • Logcat log buffer is a rotation ring buffer in memory, the buffer size is typically 256KB (you can config to 64KB~16MB).

    As a ring buffer, when the buffer is full, the oldest log entries will be dropped to store the new logs.

    So for your question 1, YES. The logcat -c will permanently deletes all logs.

    For question 2, since Google removed the READ_LOGS permission for applications after API 16(JellyBean), if you are not a root device or a system app, YOU CAN't. Otherwise, if you have system permission, you can start a background service to get logcat log into a file when device boot up.

    Hope this helps.