我有一个在服务器上运行的django-app。从黑角兽开始吧。我想让django把它的日志输出放到gunicorn的日志文件中。但是当我查看该文件时,没有django-log-entry。
我想当我在控制台上打印日志时,gunicorn会记录它。
下面是gunicorn开头的代码片段:
exec ../bin/gunicorn ${django_app_name}.wsgi:application \
-D \
-p $unicorn_pidfile \
-b unix:$unicorn_sockfile \
--log-level debug \
--log-file $unicorn_logfile \
--error-logfile $unicorn_error_logfile \
# --log-level debug \
# --log-level debug --log-file $unicorn_logfile \
#--log-level error --log-file $unicorn_error_logfile \
-w $num_workers \
--name $django_app_name > $unicorn_logfile下面是我如何(尝试)登录django (settings.py):
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': "[ThreadID: %(thread)d %(asctime)s.%(msecs)d] %(levelname)s: %(message)s",
'datefmt': "%H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
'level': 'DEBUG',
},
'rest': {
'handlers': ['console'],
'level': 'DEBUG',
},
}
}发布于 2017-01-31 19:50:50
exec ../bin/gunicorn ${django_app_name}.wsgi:application \
-D \
-p $unicorn_pidfile \
-b unix:$unicorn_sockfile \
--log-level debug \
--log-file $unicorn_logfile \
--error-logfile $unicorn_error_logfile \
# --log-level debug \
# --log-level debug --log-file $unicorn_logfile \
#--log-level error --log-file $unicorn_error_logfile \
-w $num_workers \
--name $django_app_name 只需删除脚本末尾的> $unicorn_logfile即可。--log-file $unicorn_logfile已经足够用于日志记录了。但您正在由>操作员覆盖现有日志
https://stackoverflow.com/questions/26397020
复制相似问题