How do I disable Firefox logging in Selenium using Geckodriver?

maxbfuer picture maxbfuer · Dec 29, 2016 · Viewed 15.3k times · Source

I am using:

  • firefox version 50.1.0
  • geckodriver version 0.11.1
  • selenium-java 3.0.1

I have tried

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("webdriver.log.browser.ignore", true);
profile.setPreference("webdriver.log.driver.ignore", true);
profile.setPreference("webdriver.log.profiler.ignore", true);
FirefoxDriver driver = new FirefoxDriver();

and

LoggingPreferences preferences = new LoggingPreferences();
preferences.enable(LogType.BROWSER, Level.OFF);
preferences.enable(LogType.CLIENT, Level.OFF);
preferences.enable(LogType.DRIVER, Level.OFF);
preferences.enable(LogType.PERFORMANCE, Level.OFF);
preferences.enable(LogType.SERVER, Level.OFF);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.LOGGING_PREFS, preferences);
FirefoxDriver driver = new FirefoxDriver(capabilities);

neither of these methods does anything to stop logging. Here is console output if that helps somehow:

For those wondering, i have log4j 1.2.17 in my pom.xml but have no log4j.properties or log4j.xml and I do not use it at all.


To clarify: when I say logging I mean the console output in IntelliJ IDEA. I am using Java.

Answer

Michael Medina picture Michael Medina · Sep 19, 2017

To not see the logs in the console you can use the following:

System.setProperty("webdriver.gecko.driver","src/main/resources/drivers/geckodriver.exe");
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"/dev/null");

return new FirefoxDriver();