yas*_*osi 5 python django gunicorn
I have a django site with is behind a gunicorn server. Here are the logging settings for django -
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '[%(asctime)s][%(levelname)s] %(message)s',
},
},
'handlers': {
'file': {
'level': os.environ['DJANGO_LOGLEVEL'],
'class': 'logging.FileHandler',
'filename': '/mnt/storage/logs/django.log',
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': os.environ['DJANGO_LOGLEVEL'],
'propagate': True,
},
},
}
Run Code Online (Sandbox Code Playgroud)
Here is the command which starts gunicorn server -
gunicorn training_service.wsgi -b 0.0.0.0:8000 -w 4 --access-logfile /mnt/storage/logs/access.log --log-file /mnt/storage/logs/gunicorn.log --log-level $GUNICORN_LOGLEVEL
Run Code Online (Sandbox Code Playgroud)
Now, my understanding is that both the logging frameworks should work completely independent of each other.
But when I launch the django site by calling manage.py runserver logging works are expected from the django settings.
But when I launch the same thing using the gunicorn command both the logging format and the debug logs from django disappear. I am not sure what is wrong here because disable_existing_loggers is also set to false. And I don't know if there is any setting in gunicorn which should effect django's logging functionality.
The only difference is Debug is set to False when I run with gunicorn.
Ish*_*att -1
我遇到了同样的问题,在 view.py 中,我有以下行
import logging
logger = logging.getLogger("logger_name")
Run Code Online (Sandbox Code Playgroud)
我打印了 logger.__dict__,结果发现 logger 已禁用=True 因此,在执行任何信息/调试/错误等操作之前,我将其更改为 False。
logger.disabled = False
Run Code Online (Sandbox Code Playgroud)
然后它就像一个魅力
| 归档时间: |
|
| 查看次数: |
820 次 |
| 最近记录: |