Med Dhaker Abdeljawed
Med Dhaker Abdeljawed

Reputation: 153

Java Selenium Chrome driver - Disable logging

I'm working with Selenium Chrome driver and want to disable logging, I'v tried all existing solutions including :

ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--log-level=3");

and

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        capabilities.setCapability("chrome.verbose", false);

but none worked for me, still having this Info and warning log showing up :

Starting ChromeDriver 2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e) on port 17965 Only local connections are allowed. Jul 25, 2017 7:01:16 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end Jul 25, 2017 7:01:16 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS

Upvotes: 9

Views: 11974

Answers (4)

Swaroop Humane
Swaroop Humane

Reputation: 1836

For Minimum output you can use the below code -

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

Upvotes: 1

Aday
Aday

Reputation: 91

Running chromedriver --help it states if you want to turn logging off, you need to add argument "--silent" (log nothing (equivalent to --log-level=OFF) in other words:

chromeOptions.addArgument("--silent");

Upvotes: 0

Ed Loktseu
Ed Loktseu

Reputation: 31

Only --log-level=3 works for me, tested on: Ruby, watir, selenium 3.142.3, chromedriver 75.0.3770.140 , win 10

Ruby code:

   options = Selenium::WebDriver::Chrome::Options.new

    default_options = %w[--log-level=3]
    default_options.each do |option|
      options.add_argument(option)
    end

    @driver = Watir::Browser.new :chrome, options: options

Upvotes: 0

TitusLucretius
TitusLucretius

Reputation: 181

This is what I have been doing and it has worked so far for me.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArgument("--log-level=3");
chromeOptions.addArgument("--silent");
WebDriver driver = new ChromeDriver(chromeOptions);

Upvotes: 8

Related Questions