Python 如何将ApScheduler日志写入文件?
我使用python的ApsScheduler定期运行代码。即使我的代码在一段时间内运行良好,它也会在一段时间后崩溃,我看不到任何日志输出。我正在寻找一种将调度程序日志输出到文件的方法 这是我的密码Python 如何将ApScheduler日志写入文件?,python,logging,apscheduler,Python,Logging,Apscheduler,我使用python的ApsScheduler定期运行代码。即使我的代码在一段时间内运行良好,它也会在一段时间后崩溃,我看不到任何日志输出。我正在寻找一种将调度程序日志输出到文件的方法 这是我的密码 logging.basicConfig(filename='TwitterBot/SchedulerLog.txt') #logging.basicConfig() scheduler = BlockingScheduler() scheduler.add_job(whole_run, 'int
logging.basicConfig(filename='TwitterBot/SchedulerLog.txt')
#logging.basicConfig()
scheduler = BlockingScheduler()
scheduler.add_job(whole_run, 'interval', hours=1)
#scheduler.print_jobs()
scheduler.start()
可以提供一些提示吗?这应该可以做到:
logging.basicConfig(filename='TwitterBot/SchedulerLog.txt', level=logging.INFO)
不起作用。你认为这和Ipython笔记本有关吗?如果你能详细阐述一下,会很有帮助的。“没用”并没有给我太多的理由。“it崩溃”也是如此。不带ipython试试怎么样?对。之前它没有打印出一些东西到文件中,即使在你添加之后也是如此。我正在尝试原生python而不是ipythonI。我尝试了你的脚本,它确实打印了很多行。当然,我添加了正确的导入,将
whole\u run()
作为空函数实现,并将hours=1
更改为seconds=1
。