How do I relocate/disable GeckoDriver's log file in selenium, python 3?

To relocate the GeckoDriver logs you can create a directory within your project space e.g. Log and you can use the argument log_path to store the GeckoDriver logs in a file as follows :

from selenium import webdriver

driver = webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe', log_path='./Log/geckodriver.log')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

ref: 7. WebDriver API > Firefox WebDriver

according to the documents, you can relocate it to Temp following:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options$
import os

options = Options()
driver = webdriver.Firefox(executable_path=geckodriver_path, service_log_path=os.path.devnull, options=options)

Following argument are deprecated:

  • firefox_options – Deprecated argument for options
  • log_path – Deprecated argument for service_log_path

You should be using the service_log_path, as of today the log_path is deprecated, example with pytest:

@pytest.mark.unit
@pytest.fixture
def browser(pytestconfig):
    """
    Args:
        pytestconfig (_pytest.config.Config)
    """
    driver_name = pytestconfig.getoption('browser_driver')
    driver = getattr(webdriver, driver_name)
    driver = driver(service_log_path='artifacts/web_driver-%s.log' % driver_name)
    driver.implicitly_wait(10)
    driver.set_window_size(1200, 800)
    yield driver
    driver.quit()