2

Is it possible to disable logging to the logcat for an application (APK) in Android entirely.

Since i make heavy use of my logcat output, I'd like to see only bits that are relevant to me but there are a lot of apps that write to the logcat, it is quite cluttered.

I would simply filter the output but it seems that the logcat entries only have the PID for deciding what the application is and the PID is something that changes everytime a process is restarted.

1 Answer 1

4

You can use filtering to include only the selected app's messages by the tag(s) used. Use the syntax adb logcat YourTag:I *:S to show logcat output only from YourTag and hide all others. You can have multiple tags also, just separate them with space and have the *:S entry as last.

If you need to get all messages from multiple tags in the same app, you have to fish out the PID. If you use Linux/OSX, you can use the command:

adb logcat | grep `adb shell ps | grep com.android.example | cut -c10-15`

or you can check out proclogcat and use:

adb logcat | proclogcat
5
  • This only works if you log you log all your log messages with com.android.example. If I write my logs like Log.i("MyActivity', "Something log message);, it wouldn't allow me to filter them by my package name. Commented Feb 21, 2014 at 13:34
  • @MridangAgarwalla Onik is right. You can filter with the package name separately from the log tag. If you're not comfortable setting up the filter on the command-line, use the filter GUI built into Eclipse or IntelliJ IDEA.
    – Dan Hulme
    Commented Feb 21, 2014 at 13:58
  • Grepping the logcat by the PID would only work if the PID of the application was always the same. If the PID changes e.g. the phone was rebooted, this won't work for entries prior to the reboot. Viewing the logcat live in Eclipse is easy but none of these methods work for historical logcat entries. Commented Feb 21, 2014 at 14:03
  • 1
    The command doesn't grep by PID, but by package name. It then cuts the PID and pipes it to logcat. Commented Feb 21, 2014 at 14:07
  • Unfortunately if an application is thrashing the system, not all log entries will make it into the log. For time like this, filtering doesn't really help. Surely there must be a way to stop third-party applications or services from being able to log?
    – SparkyNZ
    Commented May 6, 2020 at 3:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .