Don't show the logs in the intellij consol when start server by programming

hi i start my server by programation and the logs appear in the consol of intellij
at first i thought that was great but now i want to see only my logs in intellij and stock the appium logs outside …
if you have an idea or if you know a tuto please tell me :slight_smile:

Could you send your code here?

public static void appiumStart () throws IOException, InterruptedException {
		//Set path of your node.exe file.
		// Progra~1 represents Program Files folder.
		String nodePath = "C:\\Appium\\node.exe";
		// Set path of your appium.js file.
		String appiumJSPath = "C:\\Appium\\node_modules\\appium\\bin\\appium.js";

		// Created object of apache CommandLine class.
		// It will start command prompt In background.
		CommandLine command = new CommandLine("cmd");
		// Add different arguments In command line which requires to start appium server.
		command.addArgument("/c");
		command.addArgument(nodePath);
		command.addArgument(appiumJSPath);
		//Set Server address
		command.addArgument("--address");
		command.addArgument("127.0.0.1");
		//Set Port
		command.addArgument("--port");
		command.addArgument("4723");
		command.addArgument("--no-reset");
		command.addArgument("--log");
		//Set path to store appium server log file.
		command.addArgument("C://appiumLogs.txt");
		// Execute command line arguments to start appium server.
		DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
		DefaultExecutor executor = new DefaultExecutor();
		executor.setExitValue(1);
		executor.execute(command, resultHandler);
		// Wait for 15 minutes so that appium server can start properly before going for test execution.
		// Increase this time If face any error.
		Thread.sleep(15000);
	}

ok my bad i already stock it outside in the C://appiumLogs.txt file, but i don’t know how to remove the logs from intellij

I’m not too familiar with the Apache Commons Exec library, but I believe that the DefaultExecutor’s stream handler is just outputting Appium’s standard out to your Java process’s standard out, so you’ll be seeing both processes’ output. If you want to discard Appium’s standard out, you can set your own stream handler that just reads from Appium’s output and does nothing with it.

thx i’ll try it today or tomorrow ,
i’ll reply you again to tell the result :slight_smile:

so i finally found a solution. By searching from your issue someone told me to use the logs levels and then i just used these lines commands

command.addArgument("C://Appium//Logs//appiumLogs" + System.currentTimeMillis() + ".txt");
command.addArgument("--log-level");
command.addArgument("error");

now it’s show me only errors so when the server crash.
i don’t see anymore the infos

------> but no more info in the files where i want to stock the informations … <-------

reEdit : i just finished what you told me to do it’s work fine :smiley:

		// Execute command line arguments to start appium server.
		DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
		PumpStreamHandler streamHandler = new PumpStreamHandler(new FileOutputStream("C:\\ Device nexus Logs.txt"));
		DefaultExecutor executor = new DefaultExecutor();
		executor.setStreamHandler(streamHandler);
		executor.setExitValue(1);
		executor.execute(command, resultHandler);
1 Like