Turning off logging in Selenium (from Python)

I've recently inherited some Selenium Webdriver code, written in Python 2.7. It is logging copious amounts of data to /tmp on Ubuntu - so much that it is becoming a problem. I am trying to turn it off (or at least down).

I have been running around trying to RTFM, but this is a new version of Selenium (2.19.0) and the manuals aren't written yet!

I can see there is a method called set_browser_log_level(logLevel) which sounds promising, but to get to it, I need to instantiate a selenium.selenium.selenium object. I don't otherwise have to instantiate one of these, and it takes a lot of parameters (which host? what port?) that I am not expecting to have to provide.

Clearly, I am misunderstanding something.

Can someone please explain either (a) how to turn off logging, or (b) what service is it that selenium.selenium.selenium.selenium.selenium (I may have got carried away there, sorry!) wants to talk to?

Related question: In Selenium, how do I turn off logging? This is an older version of Selenium, and calling it from the scripting language, I believe.


Here's what helped me to overcome the problem:

import logging
from selenium.webdriver.remote.remote_connection import LOGGER

Note: this code should be put before webdriver initialization.

Hope that helps.

import logging
selenium_logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
# Only display possible problems

Do you use some logger? I had a very similar issue? i used a simple logging.basicConfig, but Selenium does this as well. My solution was to define my own logger.

Maybe you print some Code samples.

The answer from alecxe worked for me. There were still some debug messages in the log however, originating from urllib3. It is imported by selenium, and not affected by the solution above. Here is what I used, for what it's worth:

# Set the threshold for selenium to WARNING
from selenium.webdriver.remote.remote_connection import LOGGER as seleniumLogger
# Set the threshold for urllib3 to WARNING
from urllib3.connectionpool import log as urllibLogger

If someone knows of more pythonic way to achieve the same - I'll be glad to hear it.

Need Your Help

C# / .NET equivalent for Java Collections.<T>emptyList()?

c# collections generic-collections

What's the standard way to get a typed, readonly empty list in C#, or is there one?

To STL or !STL, that is the question

c++ stl containers

Unquestionably, I would choose to use the STL for most C++ programming projects. The question was presented to me recently however, "Are there any cases where you wouldn't use the STL?"...