Based on scrapy documentatnion I configured some logging settings:
LOG_LEVEL = 'INFO'
LOG_FORMAT = '%(asctime)s [%(name)s] [%(levelname)s] %(message)s'
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
It looks like it does not work.
What I would expect, there will be only INFO logs with defined LOG and DATE format but it does not work, this is an example of some logs:
DEBUG:scrapy.utils.log:Using reactor: twisted.internet.asyncioreactor.AsyncioSelectorReactor
DEBUG:scrapy.utils.log:Using asyncio event loop: asyncio.unix_events._UnixSelectorEventLoop
DEBUG:spidername:URL: https://www.somepage.com/123123123
I tried also LOG_ENABLED = False
but it does not work at all.
I tried this:
logging.getLogger('scrapy').setLevel(logging.INFO)
logging.getLogger('asyncio').setLevel(logging.INFO)
But it also does not work and this is some logs example:
DEBUG:scrapy.utils.log:Using reactor: twisted.internet.asyncioreactor.AsyncioSelectorReactor
DEBUG:scrapy.utils.log:Using asyncio event loop: asyncio.unix_events._UnixSelectorEventLoop
Only way to change “something” is this:
logging.basicConfig(
format=LOG_FORMAT,
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S',
)
This changed only LOG and DATE format, but there are still DEBUG logs. If I want to configure Spider log level, I have to do it in spider with self.logger.setLevel(LOG_LEVEL)
.
Why settings works only partially and how to fix this? I do not want to configure multiple loggers in multiple places. It looks like best practice of python logging is not working here.
Scrapy version: 2.11.2