I have to execute my test on more then one device. So how to get logcat for every device?

My current code is:

List logEntries = driver.manage().logs().get("logcat").getAll();
File logFile = new File(logPathWithFile);
PrintWriter log_file_writer = new PrintWriter(logFile);
for (LogEntry temp : logEntries) {

This only creates one file.

2 Answers 2


If you have multiple devices attached to your system, you can get logs for specific device by following the below mentioned steps:

1.Get the device id of your device.
You can get this by running the command adb devices in your terminal.
2.Now use the following command:

adb -s serialNumberOfDevice logcat

This will give logs specific to the device whose serialNumber has been given in the adb command.

Hope it helps

  • Thank you for your response but i want that log into one file and i have to send that file via mail through java mail API. i am using github.com/appium/appium/issues/970 please check my code too. Oct 29, 2015 at 11:47
  • adb -s serialNumberOfDevice logcat > logcat_dev_1.txt, repeat for devices 2...N and concatenate. BUT from my experience using adb in parallel to appium will cause problems and introduce instability to your test system.
    – Rsf
    Oct 29, 2015 at 14:45
  • @rsf i don't want to do this manually like open terminal and write that command. so how can i do automation for the same. Oct 30, 2015 at 6:22
  • look for your programming language equivalent of System command.
    – Rsf
    Oct 30, 2015 at 8:30

You need to set serialNumberOfDevice to udid in capabilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.