Selenium wire hide redundant logging
I am using SeleniumWire, Django, Celery for parsing
I have a lot of redundant logs from selenium-wire. I mean logs:
Capturing request: sitename
Capturing response: sitename 200 OK
I want to hide these logs. How to configure logger/driver to hide selenium-wire logs?
I am using regular logger:
import logging
logger = logging.getLogger(__name__)
My Django logging settings:
# settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s:%(lineno)s- %(message)s'
},
},
# django uses some of its own loggers for internal operations. In case you want to disable them just replace the False above with true.
# A handler for DEBUG. It is basically writing the DEBUG messages into a file called DJANGO_DEBUG.log
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
},
# A logger for DEBUG which has a handler called 'file'. A logger can have multiple handler
'loggers': {
# notice the blank '', Usually you would put built in loggers like django or root here based on your needs
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
},
}
It looks like you need to override the selenium wire logger
selenium_logger = logging.getLogger('seleniumwire')
selenium_logger.setLevel(logging.ERROR)
You can either set this
1. in Django logging settings
'loggers': {
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'seleniumwire': {
'handlers': ['console'],
'level': 'WARNING', # Change to WARNING or ERROR to suppress INFO logs
'propagate': False,
},
},
2. at a Python level
import logging
import seleniumwire
logging.basicConfig(level=logging.DEBUG)
seleniumwire_logger = logging.getLogger('seleniumwire')
seleniumwire_logger.setLevel(logging.WARNING)