Forrest logo
back to the adb tool

adb-logcat:tldr:15c92

adb-logcat: Display logs for the process of a specific package.
$ adb logcat --pid=$(adb shell pidof -s ${package})
try on your machine

This command is used to retrieve logs generated by the Android operating system and applications running on an Android device.

Here's a breakdown of the command:

  • adb: Stands for Android Debug Bridge, a command-line tool used for various debugging and development tasks on Android devices.
  • logcat: It is a command used with adb to access and view logs from the device.
  • --pid=: This flag is used to specify the PID (Process ID) for which logs are to be displayed.
  • $(adb shell pidof -s ${package}): This part of the command retrieves the PID of the specified package.

Let's break down the sub-command adb shell pidof -s ${package}:

  • adb shell: Runs a shell command on the connected Android device.
  • pidof: A shell command used to find the PID of a running process.
  • -s: This option is used to only output a single PID.
  • ${package}: This is a variable that should be replaced with the name of the package (e.g., com.example.app) for which you want to retrieve the PID.

So, by running the adb logcat --pid=$(adb shell pidof -s ${package}) command, you will get the logs specifically for the process with the given package name.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the adb tool