DEV Community

drake
drake

Posted on

scrapy自定义的extension日志被打印两次的问题

  • 样例
2025-03-20 10:58:40,853 - Extension - INFO - Coingecko_liquidity Idle 爬虫上次启动时间为 2025-03-20 10:58:27
2025-03-20 10:58:40 [Extension] INFO: Coingecko_liquidity Idle 爬虫上次启动时间为 2025-03-20 10:58:27

Enter fullscreen mode Exit fullscreen mode

代码中只打印了一次,但是实际运行程序会打印两次

  • 在settings文件中加一行配置
# 禁用默认日志捕获,防止重复的日志打印
LOG_ENABLED = False
Enter fullscreen mode Exit fullscreen mode

该配置不会忽略所有的日志打印,该正常打印的信息,都还是会打印的,只是不会重复打印了;
解决了重复打印的问题

Top comments (0)

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️