Modify logging level on Selenium Firefox driver?

Viewed 4359

I'm running tests for a Java/Maven project using Selenium 3.4 and the FirefoxDriver (not the Marionette/Geckodriver). I have Firefox 45.9.0 installed. Our test code uses Log4j2 and I can set the logging level to whatever I like, but no matter what I set it to I get log messages like this in the console:

1501873908911   addons.manager  DEBUG   Application has been upgraded
1501873909216   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1501873909218   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1501873909220   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm
1501873909221   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm
1501873909221   addons.manager  DEBUG   Starting provider: XPIProvider
1501873909221   addons.xpi  DEBUG   startup
1501873909222   addons.xpi  INFO    Mapping fxdriver@googlecode.com to C:\TMP\anonymous3169069284131523935webdriver-profile\extensions\fxdriver@googlecode.com
1501873909222   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: C:\TMP\anonymous3169069284131523935webdriver-profile\extensions\webdriver-staging
1501873909223   addons.xpi  INFO    SystemAddonInstallLocation directory is missing
1501873909224   addons.xpi  INFO    Mapping loop@mozilla.org to C:\Program Files (x86)\Mozilla Firefox\browser\features\loop@mozilla.org.xpi
1501873909226   addons.xpi  INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
1501873909226   addons.xpi  DEBUG   Skipping unavailable install location app-system-share
1501873909226   addons.xpi  DEBUG   Skipping unavailable install location app-system-local

It looks like something inside the FirefoxDriver, or inside Firefox itself, is logging at a DEBUG level no matter what I set our logging level to.

I looked at this question but I can't figure out how to translate the Python answer to our Java code:

Example Python:

import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING)

Our Java code:

DesiredCapabilities capability = DesiredCapabilities.firefox();
FirefoxProfile profile=new FirefoxProfile();
capability.setCapability(FirefoxDriver.PROFILE, profile);
mDriver = new FirefoxDriver(capability);

I've tried several permutations but nothing seems to affect this logging - these messages appear in the console no matter what. Anyone have any way to control this logging?

2 Answers

Sorry to dig up an old thread but just wanted to give an updated solution (latest driver version is 0.23.0 as of writing).

Official Docs: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html

Here's the Java example in the documentation above. You can specifiy the logging level by including it in the .setLogLevel method of FirefoxOptions class.

FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.TRACE);
WebDriver driver = new FirefoxDriver(options);

You can refer to the documentation for the different levels of logging.

Related