关于Supervisor和关于Apache的错误.log的说明

时间:2017-06-02 10:49:48

标签: docker tail supervisor docker-entrypoint

在创建Docker容器时,同时拥有 apache2 error.log并通过docker logs -f <my_container>拖尾它我使用运行主管的容器作为< strong>入口点使用此配置:

[supervisord]
nodaemon = true
environment = PLACEHOLDER=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:apache]
command=apache2ctl -DFOREGROUND
autostart=true
autorestart=true
startretries=1
startsecs=1
stderr_logfile=/var/log/apache2/error.log
stdout_logfile=/var/log/apache2/access.log
user=root
killasgroup=true
stopasgroup=true

[program:apache2-error]
command= tail -f /var/log/apache2/error.log
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:apache2-access]
command= tail -f /var/log/apache2/access.log
autostart = true
autorestart = true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

这样做很好,但我不明白为什么如果用这个替换[program:apache]会话,这不起作用:

[program:apache]
command=apache2ctl -DFOREGROUND
autostart=true
autorestart=true
startretries=1
startsecs=1
user=root
killasgroup=true
stopasgroup=true

即:没有显式设置stderrstdout日志文件,docker logs -f <my_container>命令不起作用,但容器tail -f /var/logs/apache2/access.logtail -f /var/logs/apache2/error.log内部工作正常。< / p>

有人可以解释为什么supervisordocker logs -f <my_container>由于此配置更改而有两个不同的作品?

由于

1 个答案:

答案 0 :(得分:1)

主管可以'看到'apache2的stdout并将其写入您使用 stdout_file 指定的文件。问题是apache2没有将访问日志写入stdout,而是将其写入/ var / log / apache2中的文件。

因此,您在docker logs -f中看到的是主管对您在stdout_file中提供的文件所做的拖尾,并且主管在您配置时将其转发到自己的stdout[supervosord]

因此,当您从主管中删除apache2日志文件config时,没有这样的转发;并且apache2继续写入与以前相同的文件。

因此,您需要做的是告诉Apache将其访问日志写入/ dev / stdout而不是磁盘中的文件。您可以在Apache虚拟主机配置中执行此操作。

stderr也是如此。