'Start Appium in Background and save logs in a file without printing them in terminal

I have a shell script which looks like this

set -o xtrace                     #traces commands before executing them
echo hello world
echo starting appium here in background
appium &
echo I have some other processes here 

I want to start the process of appium in background and print its logs in a new file. I does not want them to be available in console when I run the script.

Side by side I want other processes to run as usual.

Here are the commands that I have tried:

appium &> appiumLogs.log
appium &> appiumLogs.log &
appium &>> appiumLogs.log &

But in all cases appium process was running in background but never saved logs in file appiumLogs.



Solution 1:[1]

You can use AppiumServiceBuilder for that.

service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().. .................... .withLogFile(new File("AppiumLog.text"))

service.start();

Log will be saved in new file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rakeshsahu59