如何更改主管启动的进程的stdout和stderr日志位置?

时间:2017-09-14 05:07:22

标签: gunicorn supervisord

所以在我的系统中,主管将stderr和stdout捕获到这些文件中:

root@3a1a895598f8:/var/log/supervisor# ls -l
total 24
-rw------- 1 root root 18136 Sep 14 03:35 gunicorn-stderr---supervisor-VVVsL1.log
-rw------- 1 root root     0 Sep 14 03:35 gunicorn-stdout---supervisor-lllimW.log
-rw------- 1 root root     0 Sep 14 03:35 nginx-stderr---supervisor-HNIPIA.log
-rw------- 1 root root     0 Sep 14 03:35 nginx-stdout---supervisor-2jDN7t.log
-rw-r--r-- 1 root root  1256 Sep 14 03:35 supervisord.log 

但我想将gunicorn的stdout和stderr日志文件的位置更改为/ var / log / gunicorn并修复文件名以进行监视。

这是我在配置文件中所做的:

[program:gunicorn]
stdout_capture_maxbytes=50MB
stderr_capture_maxbytes=50MB
stdout = /var/log/gunicorn/gunicorn-stdout.log
stderr = /var/log/gunicorn/gunicorn-stderr.log
command=/usr/bin/gunicorn -w 2 server:app

然而它根本没有任何效果。我错过了配置中的任何内容吗?

1 个答案:

答案 0 :(得分:0)

stdoutstderr更改为stdout_logfilestderr_logfile,这可以解决您的问题。

您还可以在主配置中更改childlogdir,以使所有子日志显示在另一个目录中。如果您使用的是自动日志模式,则日志文件名称将自动生成到指定的childlogdir中,而无需您设置stdout_logfile

为了反映您的更改,您需要使用以下命令重新启动主管服务:

service supervisord restart

重新加载配置supervisorctl reload并更新正在运行的进程supervisorctl update中的配置。

有关此问题的文档可在http://supervisord.org/logging.html#child-process-logs

找到
相关问题