How to capture android Log using Appium in Ubntu

I am working and ubntu and trying to capture android logs.
I don’t have any idea how to perform this. Please suggest me ?

I hope you can start server as given in below code, just give path of log file, so it will automatically write all server logs to this file.

AppiumDriverLocalService service;
service = AppiumDriverLocalService
.buildService(
new AppiumServiceBuilder()
.usingDriverExecutable(new File("/usr/nodejs/node"))
.withAppiumJS(new File("/usr/xmls.ja/Appium/node_modules/appium/bin/appium.js"))
.withLogFile(new File("/usr/xmlns.ja/AppiumServerLogs.txt"))
.withArgument(GeneralServerFlag.UIID, “dddd”)
.withIPAddress(“127.0.0.1”)
.usingPort(4725)
);

I think they might be asking about the Android Logcat logs rather than Appium server logs.

The WebDriver API contains a method to retrieve the logs from the test. If you’re using Java, take a look at the Selenium Javadoc for this exact method. You’ll have to experiment a bit to see what you need to do to retrieve the logcat logs.

Alternatively, if your tests and Appium are running on the same machine, then your device should also be connected with the machine your tests are running on. You can spawn a process using the command adb logcat, and you can read the standard out from this process to read the device’s logcat logs.

Good answer here: http://stackoverflow.com/questions/28557828/appium-how-to-get-adb-logcat

@deadmoto
I have a query logcat will get me logs for entire device , which I may not be required,
e.g. logs for click of all app installed on my phone which I use, internet related, call related entire logs etc
may be what I is required is only AUT logs … Kindly correct me if I am wrong ?

Thanks…

Here is a snippet we use to filter out logs:
log = getAndroidDriver().manage() .logs() .get("logcat") .getAll() .stream() .map(LogEntry::toString) .filter(s -> !s.contains("ACTION_ACCESSIBILITY_FOCUS")) .filter(s -> !s.contains("D/dalvikvm")) .filter(s -> !s.contains("E/AccessibilityNodeInfoCache")) .filter(s -> !s.contains("E/OpenGLRenderer")) .filter(s -> !s.contains("I/chromium")) .filter(s -> !s.contains("I/dalvikvm")) .filter(s -> !s.contains("I/LibraryLoader")) .filter(s -> !s.contains("I/QueryController")) .filter(s -> !s.contains("W/ResourceType")) .collect(Collectors.joining("\n"));

@amitjaincoer191 : tried your code but it do not print any log.
just blank file why?

@mykola-mokhnach : as i said i’m not programmer, i tried so many times but not getting result. i don’t know how to use this code.

can any one help to get appium server log while starting appium programmatically.

please share code if possible.