-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
What happened?
I'm not sure if this is a bug or a documentation issue, but I am unable to get any logging working from the Python bindings using the logging instructions from the official docs.
According to the Python examples in the docs, DEBUG level logging to the console can be enabled with:
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
The following code should open Chrome and load a url, while displaying DEBUG level logs to the console:
import logging
from selenium import webdriver
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
with webdriver.Chrome() as driver:
driver.get('https://example.com')
However, nothing is displayed to the console.
I can enable DEBUG logging globally for all modules, with:
logging.basicConfig(level=logging.DEBUG)
This works... The following code opens Chrome and loads a url, while displaying DEBUG level logs to the console:
import logging
from selenium import webdriver
logging.basicConfig(level=logging.DEBUG)
with webdriver.Chrome() as driver:
driver.get('https://example.com')
I get the full set of logs doing that... but this isn't ideal since it enables logging for every module and doesn't allow more fine-grained adjustments.
So why does the first example not display any logs? Either there is something wrong with logging in selenium, or the docs are not correct (or I have somehow misinterpreted them).
How can we reproduce the issue?
See description above.Relevant log output
N/AOperating System
All OS
Selenium version
Python Selenium 4.29.0
What are the browser(s) and version(s) where you see this issue?
All browsers
What are the browser driver(s) and version(s) where you see this issue?
All drivers
Are you using Selenium Grid?
No