2017-06-02 42 views
1

在创建多克尔集装箱,同时拥有的Apache2error.log和尾部它通过docker logs -f <my_container>我使用运行主管容器入口点与此配置:说明关于监事和尾巴在Apache的error.log中

[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内工作正常。

有人能解释我为什么supervisordocker logs -f <my_container>由于在该配置的改变两个不同的作品?

感谢

回答

1

监督员可以“看”的Apache2的标准输出,并写下你与stdout_file指定文件。问题是apache2不会将它的访问日志写入stdout,而是将它写入/ var/log/apache2中的文件。

所以,你看到在docker logs -f是该尾矿上司做您在stdout_file提供和系统管理员被转发到自己的stdout如您在[supervosord]配置文件。

因此,当您从管理员中删除apache2日志文件配置时,没有这样的转发;和apache2继续写入与以前相同的文件。

所以,你需要做的是告诉Apache的访问日志写入/ dev /标准输出,而不是在磁盘上的文件。您可以在Apache虚拟主机配置中执行此操作。

stderr同样的事情。

+0

谢谢您的回答,但我不明白一件事:理论上一节'[程序:Apache2的访问]'部分拖尾'access.log'文件,所以我认为从输出本节来临应该由'docker logs -f'捕获。为什么不是这样? –