How to run logcat on multiple devices?

99封情书 提交于 2019-12-08 22:48:05

问题


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

回答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"



回答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



回答3:


Use your device ip:
adb -s device_ip:5555



来源:https://stackoverflow.com/questions/6203240/how-to-run-logcat-on-multiple-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!