Launching and stopping appium server programmtically


#205

try to start the server like this, not by giving node path in cmd.

private static AppiumDriverLocalService service;
private static Logger log = LogManager.getLogger(AppiumSetup.class.getName());

public static void startServer(){
	AppiumServiceBuilder builder;
	log.info("Building and starting the server:");
	builder = new AppiumServiceBuilder();
	builder.usingPort(4723);
	builder.withCapabilities(capabilities);
	builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
	builder.withArgument(GeneralServerFlag.LOG_LEVEL, LogLevel);
	service = AppiumDriverLocalService.buildService(builder);
	service.start();
	log.info("Server started on Port - " + 4723);
}

public static void stopServer() {
	try {
		log.info("Trying to stop the server...");
		service.stop();
		log.info("Success, Server stopped.");
	} catch (Exception e) {
		log.info("Appium server could not be stopped.");
	}
}

#206

Thank you @Zuzeac Iā€™m able to open appium server. To show all my server logs in command prompt what can we do. With your code it is showing server logs in my eclipse console.
I want to see server logs and console logs separately


#207

change log level, debug, error, info:
builder.withArgument(GeneralServerFlag.LOG_LEVEL, debug);


#208

I still get the server logs in my console.

builder.withArgument(GeneralServerFlag.LOG_LEVEL, LogLevel);
builder.withArgument(GeneralServerFlag.LOG_LEVEL, debug);

For loglevel and debug I have to create local variables and initialize it right


#209

LOG_LEVEL in my case its a local variabile which is set to error. I do not need the logs. But you should just use error if you do not need logs from appium.
builder.withArgument(GeneralServerFlag.LOG_LEVEL, error);