python - celery logging in django -
i have gone through lot of questions regarding on so, of questions missing parameters or implementation methods. so, i'm not able debug this.
my simple requirement want log all(django , celery) messages single file. logging
dict
in settings.py
logging = { 'version': 1, 'disable_existing_loggers': false, 'formatters': { 'standard': { 'format': '%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)s - %(funcname)s() ] %(name)s: %(message)s' }, }, 'handlers': { 'default': { 'level': 'info', 'formatter': 'standard', 'class': 'logging.handlers.timedrotatingfilehandler', 'filename': 'logger.log', 'when': 'midnight', 'interval': 1 } }, 'loggers': { '': { 'handlers': ['default'], 'level': 'info', 'propagate': false } } } celeryd_hijack_root_logger = false
then have defined function:
@shared_task def tester(): import logging logging.info("log this!!")
tester()
writing log file.
tester.delay()
not writing log file.
what missing in simple thing?
if want define default log level, use root key in logging dict:
... 'root': { 'handlers': ['default'], 'level': 'debug' }, 'loggers': {...} ....
in theory, '' loggers's key should work, haven't seen in while , know @ least in 1 projects didn't work expected.
see https://docs.python.org/2/library/logging.config.html#dictionary-schema-details
Comments
Post a Comment