我在ngninx后面运行gunicorn。我想在gunicorn-error.log中记录错误,并将日志记录到gunicorn-access.log。无法访问日志为gunicorn工作
我有错误日志工作,但没有访问日志,我做错了什么?
这是我gunicorn.conf.py:
bind = '127.0.0.1:8888'
backlog = 2048
workers = 3
errorlog = '/home/my/logs/gunicorn-error.log'
accesslog = '/home/my/logs/gunicorn-access.log'
loglevel = 'debug'
proc_name = 'gunicorn-my'
pidfile = '/var/run/my.pid'
这是运行gunicorn脚本:
#!/bin/bash
set -e
ENV=/home/my/env/bin/activate
GUNICORN=gunicorn_django
SETTINGS_PATH=/home/my/app/app/settings
PROJECT_PATH=/home/my/app
CONFROOT=/home/my/app/conf/gunicorn.conf.py
cd $SETTINGS_PATH
source $ENV
export PYTHONPATH=$PROJECT_PATH
exec $GUNICORN app.settings.staging -c $CONFROOT
它创建两个gunicorn-error.log中和gunicorn-access.log的,但只有gunicorn-error.log中获得任何日志,比如:
2012-11-20 11:49:57 [27817] [INFO] Starting gunicorn 0.14.6
2012-11-20 11:49:57 [27817] [DEBUG] Arbiter booted
2012-11-20 11:49:57 [27817] [INFO] Listening at: http://127.0.0.1:8888 (27817)
2012-11-20 11:49:57 [27817] [INFO] Using worker: sync
2012-11-20 11:49:58 [27825] [INFO] Booting worker with pid: 27825
2012-11-20 11:49:58 [27828] [INFO] Booting worker with pid: 27828
2012-11-20 11:49:58 [27830] [INFO] Booting worker with pid: 27830
我在做什么错?任何人都想分享他们的工作gunicorn.conf.py与错误日志和访问日志?
谢谢!也许更好的日志在那里。 – Mikael
问题在于文件处理程序不能通过多个进程登录。 – dalore
只要fyi万一其他人遇到这种情况,为Formatter指定一个特定的类,关键是'“()”'不是“class”,类的关键是处理程序。文档中提到[此处](https://docs.python.org/2/library/logging.config.html#logging-config-dictschema)。 – danny