How to run logcat on multiple devices?

32,208

Solution 1

Use the -s option of adb:

adb -s <serialnumber>

Example

C:\Users\lel>adb devices
List of devices attached
192.168.198.101:5555    device
0123456789ABCDEF        device

adb -s 0123456789ABCDEF logcat
adb -s 192.168.198.101:5555 logcat

You can combine grep whit this, to get all lines that contain it.
an example is with System.out

Example:

 adb -s 192.168.198.101:5555 logcat | grep "System.out"

Solution 2

I thought it might be useful. I have this script that helps me a lot. It logcats each device to a different file. To stop logging just press CTRL+C.

#! /bin/bash

devices=`adb devices | grep 'device$' | cut -f1`
pids=""

for device in $devices
do
    log_file="$device-`date +%d-%m-%H:%M:%S`.log"
    echo "Logging device $device to \"$log_file\""
    adb -s $device logcat -v threadtime > $log_file &
    pids="$pids $!"
done

echo "Children PIDs: $pids"

killemall()
{
    echo "Killing children (what a shame...)"

    for pid in $pids
    do
        echo "Killing $pid"
        kill -TERM $pid
    done
}

trap killemall INT

wait
Share:
32,208

Related videos on Youtube

Kostas
Author by

Kostas

Updated on September 24, 2020

Comments

  • Kostas
    Kostas almost 4 years

    How can I run logcat on multiple devices at the same time? "adb logcat" command gives an error:

    error: more than one device and emulator
    
  • Kostas
    Kostas about 13 years
    I guess I will pay more attention to adb parameters next time... Sorry for bringing up such an obvious problem. :)
  • Lukap
    Lukap almost 13 years
    how did you get the serialnumber ? I tried with adb devices but that give me this List of devices attached HT05XPL09783 device 100082a42935 device and adb logcat -s 100082a42935 doesn't work
  • Lukap
    Lukap almost 13 years
    I found my stupid mistake it should stay like adb -s 100082a42935 logcat