1

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.

3

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
  • 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. – Mridang Agarwalla Feb 21 '14 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 Feb 21 '14 at 13:58
  • Sorry about that, see fixed post – onik Feb 21 '14 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. – Mridang Agarwalla Feb 21 '14 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. – onik Feb 21 '14 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.