Java/Selenium: Still getting "ChromeDriver was started successfully" message after disabling logging

Viewed 1540

I'm using the Selenium Chromedriver with Java. I don't want it to output any logs/messages in the console. Therefore I used the following code:

    System.setProperty("webdriver.chrome.silentOutput", "true");
    System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
    Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);

However, I'm still getting a single message: "ChromeDriver was started successfully". How can I prevent this message?

2 Answers

You can redirect the output to a file or just discard it:

            // redirect console output from chromedriver to the file chromedriver_log.txt in the target folder
            DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> serviceBuilder = new ChromeDriverService.Builder();
            ChromeDriverService chromeDriverService = serviceBuilder.build();
            chromeDriverService.sendOutputTo(new FileOutputStream("target/chromedriver_log.txt", true));

            webDriver = new ChromeDriver(chromeDriverService, options);

If you want to just discard the output then use NullOutputStream.NULL_OUTPUT_STREAM insted off new FileOutputStream("target/chromedriver_log.txt", true)

I have found that the "ChromeDriver was started successfully" message comes from this line at the ChromeDriver binary:

printf("%s was started successfully.\n", kChromeDriverProductShortName);

Maybe this printf statement that ends in the standard output, can be redirected somehow.

Related