Python 找不到记录器“apscheduler.scheduler”的处理程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17528363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 08:25:41  来源:igfitidea点击:

No handlers could be found for logger "apscheduler.scheduler"

pythonscheduler

提问by Dyllian

from apscheduler.scheduler import Scheduler
import os
class ListHref():
    def __init__(self):
       print 'In ListHref Class!'
       self.name_hrefs = {}
       self.name_img = {}
       self.path = os.path.dirname(__file__)
       print 'Out ListHref Class'
    def other_function():...

def job(): #function named job
    print 'In job!'
    book_href = ListHref()
    print 'book_href created!'

if __name__ == "__main__":
    sched = Scheduler()
    #job() #it's ok if job() called only
    sched.daemonic = False #non daemon thread 
    sched.add_interval_job(job,minutes=0.1)
    sched.start()

Problem:If call job() only instead of sched,it's ok So I am confused that why the init(self) cannot called completely? and what's wrong with 'No handerls could be found for logger "apscheduler.scheduler"'? Above python code result:

问题:如果只调用 job() 而不是 sched,没关系 所以我很困惑为什么init(self) 不能完全调用?并且“找不到记录器“apscheduler.scheduler”的处理程序有什么问题? 以上python代码结果:

In job()

在工作()

In ListHref Class!

在 ListHref 类中!

No handerls could be found for logger "apscheduler.scheduler"

找不到记录器“apscheduler.scheduler”的处理程序

In job()

在工作()

In ListHref Class!

在 ListHref 类中!

In job()

在工作()

In ListHref Class!

在 ListHref 类中!

...(so on)

...(很快)

采纳答案by tdelaney

apscheduler is using the python logging modulewhich needs to be initialized. Logging is a bit complicated (see the link) but the minimum is to:

apscheduler 正在使用需要初始化的 python日志记录模块。日志记录有点复杂(请参阅链接),但最低限度是:

import logging
logging.basicConfig()

basicConfig supports some common logging features but its worth figuring out some of the more sophisticated uses for the logger.

basicConfig 支持一些常见的日志记录功能,但它值得弄清楚记录器的一些更复杂的用途。