Selenium chromedriver disable logging or redirect it java

Drunk Cat :

I am trying to use selenium in a mini web crawler to get the page source. My output log is invaded by selenium logs, is there a way to totally disable the logging or just redirect it in someway to /dev/null?

The logging messages are these:

Starting ChromeDriver 2.43.600233 
(523efee95e3d68b8719b3a1c83051aa63aa6b10d) on port 1628
Only local connections are allowed.
ott 24, 2018 7:52:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMAZIONI: Detected dialect: OSS

I am calling the driver in the following way:

WebDriver driver = null;
            try {
            System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
            ChromeOptions chromeOptions = new ChromeOptions();
            chromeOptions.setBinary("/usr/bin/chromium");
            chromeOptions.addArguments("--headless");
            chromeOptions.addArguments("--silent");
            chromeOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
            driver = new ChromeDriver(chromeOptions);
            /*FirefoxBinary firefoxBinary = new FirefoxBinary();
            firefoxBinary.addCommandLineOptions("--headless");
            System.setProperty("webdriver.gecko.driver", "/usr/local/bin/geckodriver");
            System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
            System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");


            FirefoxOptions firefoxOptions = new FirefoxOptions();
            firefoxOptions.setBinary(firefoxBinary);
            FirefoxDriver driver = new FirefoxDriver(firefoxOptions);*/
            if(driver!=null) {
            driver.get(link);
Drunk Cat :

Ok i have managed to finally get rid of that useless loggings. Here is what i did.
Use:
System.setProperty("webdriver.chrome.silentOutput", "true");

To get rid of chromedriver logs:

Starting ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d) on port 1628 Only local connections are allowed.


And use: java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
To get rid of selenium logs:

ott 24, 2018 7:52:01 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFORMAZIONI: Detected dialect: OSS

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=84840&siteId=1