5

Our team is deploying a selenium grid using docker. The default log level appears to be set to INFO. I'd like to set it to something higher, SEVERE or turn them completely off. I've made three attempts, but so far, to no effect.

Method One:

From the selenium client, I've tried to set LoggingPreferences on the RemoteWebDriver within DesiredCapabilities:

DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.BROWSER, Level.SEVERE);
logs.enable(LogType.CLIENT, Level.SEVERE);
ogs.enable(LogType.DRIVER, Level.SEVERE);
logs.enable(LogType.SERVER, Level.SEVERE);
desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);
desiredCapabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new RemoteWebDriver(new URL(host:4444/wd/hub"), 
                                           desiredCapabilities);

Method 2: I tried to change the profile preferences:

FirefoxProfile profile = new FirefoxProfile();

profile.setPreference("webdriver.log.driver", "OFF");
profile.setPreference("webdriver.log.file","/dev/null");

Method 3: I tried to modify config.json in the container located in /opt/selenium/config.json:

{
  "capabilities": [
    {
      "browserName": "*firefox",
      "maxInstances": 1,
      "seleniumProtocol": "Selenium"
    },
    {
      "browserName": "firefox",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "configuration": {
      "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
      "maxSession": 1,
      "port": 5555,
      "register": true,
      "registerCycle": 5000,
      "logLevel":FATAL
  }
}

So far I've been unable to do anything that has altered the logging behavior.

Scott Turley
  • 319
  • 3
  • 8
  • I did get this to work in a very blunt way... I took selenium-node-firefox as my base image and modified the command that kicks off selenium to re-route standard out to /dev/null. Would prefer to just increase the log level. – Scott Turley May 23 '16 at 23:01

1 Answers1

3

@Scott

The Selenium codebase uses the Java Utils Logger. So maybe you can try passing in a custom logging.properties wherein the log levels are bumped up and see if that helps. [ See here to know a bit more about logging.properties ]

The LoggingPreferences class is mainly used to tweak the log levels that are to be retrieved only for a given session [ atleast that's what I think it is ] and it doesn't alter the logging level of the JVM that the node/grid runs under.

In the case of Selenium server standalone, the log levels can be changed via the JVM argument "selenium.LOGGER.level"

Community
  • 1
  • 1
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • Thanks, though I'm still having trouble getting this to work... Just getting out of docker completely and trying this: java -Djava.util.logging.config.file=./logging.properties -jar selenium-server-standalone.jar -role node I'm still seeing logs at INFO. – Scott Turley May 23 '16 at 22:07
  • Scott- I looked through the selenium codebase. If you wanted to turn on logs at WARNING level, then you need to use the JVM argument "selenium.LOGGER.level" Ex : java -Dselenium.LOGGER.level=WARNING -jar selenium-server-standalone-2.53.0.jar Please try again using the above mentioned JVM argument. – Krishnan Mahadevan May 24 '16 at 02:42
  • Thanks Krishnan, this worked. Next time look at the source code :-). – Scott Turley May 24 '16 at 16:56