44

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
  • 2,294
  • 3
  • 17
  • 17

3 Answers3

80

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"
DarckBlezzer
  • 3,504
  • 1
  • 33
  • 44
levis501
  • 3,753
  • 20
  • 22
  • 1
    I guess I will pay more attention to adb parameters next time... Sorry for bringing up such an obvious problem. :) – Kostas Jun 01 '11 at 15:12
  • 1
    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 Jun 29 '11 at 11:16
  • 3
    I found my stupid mistake it should stay like adb -s 100082a42935 logcat – Lukap Jun 29 '11 at 11:17
11

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
Gustavo Meira
  • 2,265
  • 2
  • 20
  • 30
0

Use your device ip:
adb -s device_ip:5555

pbaranski
  • 17,946
  • 16
  • 88
  • 101