Search code examples
androidloggingmobileadbtimber-android

Filter android adb logs in terminal when using Timber


In my app, I am using Timber as a logger. I am accessing the logs from the terminal via adb using this isntruction:

./adb logcat com.company.my_app:D

I do get the logs but the issue is that I am getting a crazy amount of noise from the OS (ie SurfaceFlinger , GraphicBuffer, vndksupport) which make the logs harder to read.

Is there a way to filter the logs like in Android Studio and just get logs from my app. Thank you !

P.S. I have trie a few answers from here but none of them remove the noise.


Solution

  • What works best for me is to grep for the process ID which is displayed in every log line. In the example below 7098 is printed with every log line.

    08-10 18:48:39.825  7098  7144 D NetworkModule: --> END POST
    

    So this is the adb instruction used to get filtered logs:

    adb logcat | grep -F "7098"
    

    Note: the process ID is not static and it is going to change if app is hard-closed or device is restarted.

    I don't know if it is the best solution, but it works in my case.