Python 计划包:抑制";“每运行一次作业”;信息
我正在对当前项目使用“时间表”: 这很好,但我想取消显示“每x秒运行一次作业”日志消息,该消息在每次运行计划任务时都会触发。下面是我的意思示例: 有没有办法做到这一点?下面是我当前的logging.basicConfig,我对配置日志非常陌生,因此解决方案可能更多地依赖于此:Python 计划包:抑制";“每运行一次作业”;信息,python,logging,schedule,Python,Logging,Schedule,我正在对当前项目使用“时间表”: 这很好,但我想取消显示“每x秒运行一次作业”日志消息,该消息在每次运行计划任务时都会触发。下面是我的意思示例: 有没有办法做到这一点?下面是我当前的logging.basicConfig,我对配置日志非常陌生,因此解决方案可能更多地依赖于此: # Define overall logging settings; these log levels/format go to file logging.basicConfig(level=variables.set
# Define overall logging settings; these log levels/format go to file
logging.basicConfig(level=variables.settings['log_level_file'],
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
filename='logs\log.log')
# Set up Handlers and Formatters; these log levels/format go to console
console = logging.StreamHandler()
console.setLevel(variables.settings['log_level_console'])
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
正如Meloman指出的,您可以直接将单个“schedule”记录器设置为高于默认信息的级别:
logging.getLogger('schedule').setLevel(logging.CRITICAL)
github回购协议有这样的内容。此外,还有一个选择安静工作的选项。另外,请参见此。您想将
'schedule'
记录器的级别设置为logging.DEBUG
。非常好,谢谢@Meloman,这项工作做得很好。