-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to setup logging in project? #83
Comments
After messing around, I am able to make it work. There are actually 2 different issues on each handler itself. Using FileHandler# In the cron py file
import logging
logger = logging.getLogger(__name__)
# e.g. The namespace is something like "cron_app.cron"
# ==========
# setting.py
LOGGERS = {
'formatters': {
'normal': {
'format': '[%(levelname)s] %(asctime)s | %(name)s:%(lineno)d | %(message)s'
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'normal',
},
'cron_log_file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/somewhere/scheduled_jobs.log',
'formatter': 'normal'
},
},
'loggers': {
'': {
'handlers': ['console'],
'level': 'INFO',
},
'cron_app.cron': { # The namespace of the logger above
'handlers': ['cron_log_file'],
'level': 'DEBUG',
'propagate': True,
},
}, The log will be written to However in this case, whenever we run Using StreamHandlerThis method solves the issue above. The original issue with StreamHandler is that python Just include stderr and things work like charm now. ('*/1 * * * *', 'cron_app.cron.some_func', '>> /somewhere/scheduled_jobs.log 2>&1') # Redirect all stderr to stdout destination I guess this issue is solved. Just write them down to help others and see if you have anything to add. Thanks so much. |
Situation
I have read #31 and #67. I have tried the following setting:
CRONJOBS:
Observation
This setup tests both
StreamHandler
,FileHandler
. Both doesn't work. Only an empty log file is created. I also tested/tmp/xxxxx.log
, still no luck.It is logging correctly when I run
manage.py crontab run xxxxx
, even if I do not specify'django_crontab'
logger.Question
LOGGING
in django setting such that it can work?Anyway, thanks for the great work on this package.
The text was updated successfully, but these errors were encountered: