セレンchromedriver無効ロギングやJavaのそれをリダイレクト

ドランク猫:

私は、ページのソースを取得するには、ミニウェブクローラーでセレンを使用しようとしています。私の出力ログがセレンログに侵略され、完全に無効に伐採への道か、単には/ dev / nullに何らかの方法でそれをリダイレクトはありますか?

ログメッセージは、これらのとおりです。

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

私は、次の方法でドライバを呼び出しています:

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);
ドランク猫:

[OK]を私は最終的にその役に立たないloggingsを取り除くために管理しています。ここに私がやったことです。
用途:
System.setProperty("webdriver.chrome.silentOutput", "true");

chromedriverログを取り除くために:

ローカル接続のみが許可されているポート1628上ChromeDriver 2.43.600233(523efee95e3d68b8719b3a1c83051aa63aa6b10d)を開始します。


そして、使用:java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
セレンのログを取り除くには:

24 OTT、2018午前7時52分01秒PM org.openqa.selenium.remote.ProtocolHandshakeのCreateSession INFORMAZIONI:検出方言:OSS

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=196330&siteId=1