Skip to content

Instantly share code, notes, and snippets.

@cgoldberg
Last active March 16, 2025 18:48
Show Gist options
  • Save cgoldberg/267aab305529f5107d1c89fec219ed11 to your computer and use it in GitHub Desktop.
Save cgoldberg/267aab305529f5107d1c89fec219ed11 to your computer and use it in GitHub Desktop.
Python - Enable DEBUG logging for Selenium WebDriver
import logging
# add one of these logging configurations to your selenium script to enable logging.
# 6 logger levels are supported: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.
# (default is WARNING)
# enable DEBUG logging to console for all modules globally (selenium, urllib3, etc)
logging.basicConfig(level=logging.DEBUG)
# enable DEBUG logging to console for selenium module
logger = logging.getLogger('selenium')
handler = logging.StreamHandler()
logger.addHandler(handler)
# enable DEBUG logging to file for selenium module
logger = logging.getLogger('selenium')
handler = logging.FileHandler('/path/to/log')
logger.addHandler(handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment