Python APScheduler how to disable logging

Eric Hansen picture Eric Hansen · May 26, 2013 · Viewed 7.7k times · Source

I set up APScheduler to run every second via cron schedule (kind of needed/wanted). Right now I have logger sending everything to console.

If it wasn't for logging is greatly important to what I'm working on, it'd be okay. But, I need logging. What I don't want is APScheduler's info logging. Stuff like this:

INFO     at 2013-05-26 13:05:06,007 : Job "loadavg.run (trigger: cron[year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='*', second='*'], next run at: 2013-05-26 13:05:06)" executed successfully
INFO     at 2013-05-26 13:05:06,008 : Running job "cpu.run (trigger: cron[year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='*', second='*'], next run at: 2013-05-26 13:05:07)" (scheduled at 2013-05-26 13:05:06)

I have this in my code after I add the cron jobs:

logging.getLogger("apscheduler.scheduler").setLevel(logging.DEBUG)

There's not any, as far as I know, configuration options for APScheduler to specify logging information, either.

I know I can specify the level of the logger to ERROR or something, but when it gets set to INFO I don't want all of this (what seems to be useless) information logged as well.

Answer

tupeng picture tupeng · Aug 17, 2017

You can try this code:

logging.getLogger('apscheduler.executors.default').propagate = False