Could not find handlers for the log "apscheduler.executors.default"?

I have a python script that runs through night work on Heroku. From time to time (and lately, much more), the script is not executed due to the error below.

2015-02-25T05:00:02.671242+00:00 app[clock.1]: No handlers could be found for logger "apscheduler.executors.default"

The script is executed using the built-in clock method, as defined in my Procfile.

clock.py:

import sys
import logging

sys.path.append('main')

from main import main
from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()

# Executes every night at 5:00am UTC time | 12:00am (midnight) Winston-Salem, NC time
@sched.scheduled_job('cron', hour=5)
def scheduled_job():
    logging.basicConfig()
    main()

sched.start()

I searched the Internet and based on several answers that I read, people say that this is a warning, not a mistake. However, this problem causes the entire script to crash when this happens. My question is first, is there a fix? And secondly, why does this happen sometimes, and not always ?

Many people said just add the following to the script:

import logging
logging.basicConfig()

, , , .

+4
2
import logging

log = logging.getLogger('apscheduler.executors.default')
log.setLevel(logging.INFO)  # DEBUG

fmt = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
h = logging.StreamHandler()
h.setFormatter(fmt)
log.addHandler(h)

,

+7

; , apscheduler, .

Apscheduler sys , import os; .

, ( ) .

, sys, os logger ( )

, .

+1

All Articles