No handlers could be found for logger “apscheduler.scheduler”

蓝咒 提交于 2019-12-06 17:07:55

问题


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:

In job()

In ListHref Class!

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

In job()

In ListHref Class!

In job()

In ListHref Class!

...(so on)


回答1:


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

import logging
logging.basicConfig()

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



来源:https://stackoverflow.com/questions/17528363/no-handlers-could-be-found-for-logger-apscheduler-scheduler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!