-
Notifications
You must be signed in to change notification settings - Fork 114
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
task hasn't log anything,which longging was configured in Django setting file #104
Comments
Did your problem get solved already? |
No yeat, I tried to solve this, but I haven't found a propoerty solution, and I just moved logging point to other py function which weren't called by django-crontab task. Mybe it is helpful setting the logging save path to absolute path, since I guess the django-crontab task is run in a process wich have a different pid and working directory with the Django process. |
I'm having this problem even when I'm not logging to a file, but to shell and azure through opencensus. I'm starting to think that print statements and redirecting the output&error is the most reliable way of logging from django-crontab tasks but that would be a bit heartbreaking. |
Maybe this comment solves your problem: there was the problem, that python logger writes its output to stderr and not stdout. so you need to redirect stderr to stdout by appending |
Thanks for your reply@Bergiu. I think this comment is still different from the problem I described. I want to write the logging file as the Django setting file configured, but I find that the path to the file I write to is not what I set. I think it seems that crontab forked another process to perform a timed task, and the working directory of that process is not the same as the working directory of my django process. I think one solution is that when crontab writes the log file, the file path should be specified as an absolute path, not a relative path, but this method may involve synchronization between multiple processes. |
You are right about it being a different working directory, as django-crontab creates the crontab entries and cron still runs them. That's why directing output from stdout and stderr and using an absolute path is almost the best practice solution. |
Environment & Versions
Settings
django-crontab
settings:Details
my task setting in
whatsApp_crawl_query_app.task.py
file is shown as following:The logging is setted in Django setting file. The configured log is usually recorded, but the task running shows it didn't log anything in logging file.
I am sure that the task code was actually executed, because the negative events in my task code did occur.
The text was updated successfully, but these errors were encountered: