supervisord 禁用日志文件或使用 logfile=/dev/stdout
supervisord disable log files or use logfile=/dev/stdout
[supervisord]
nodaemon=true
logfile=/dev/stdout
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor
当我这样做时,这个主管会崩溃,因为它无法在 /dev/stdout
中查找
如何禁止 supervisord 在我的 docker 容器中创建任何日志文件?
您只需删除 supervisord.conf 中的 logfile
,当您输入 docker logs <container_id> --tail=100 -f
时,每个日志都会显示为容器日志
对于主监督者,nodaemon
将导致日志转到stdout
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
然后将每个托管进程的日志发送到标准输出文件描述符/dev/fd/1
[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
或者如果您希望将 stderr 保留在不同的流上:
[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
我遇到了同样的问题,所以我查看了主管文档,找到的最佳方法是:
[program:myservice]
command=/usr/local/bin/myservice.sh
autostart=true
autorestart=true
logfile_maxbytes=0
logfile_backups=0
在我的例子中,我保留了 logfile_backup 值 3 和 maxbytes 10000000 因为我需要这个,我希望能帮助别人。
[supervisord]
nodaemon=true
logfile=/dev/stdout
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor
当我这样做时,这个主管会崩溃,因为它无法在 /dev/stdout
中查找如何禁止 supervisord 在我的 docker 容器中创建任何日志文件?
您只需删除 supervisord.conf 中的 logfile
,当您输入 docker logs <container_id> --tail=100 -f
对于主监督者,nodaemon
将导致日志转到stdout
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
然后将每个托管进程的日志发送到标准输出文件描述符/dev/fd/1
[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
或者如果您希望将 stderr 保留在不同的流上:
[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
我遇到了同样的问题,所以我查看了主管文档,找到的最佳方法是:
[program:myservice]
command=/usr/local/bin/myservice.sh
autostart=true
autorestart=true
logfile_maxbytes=0
logfile_backups=0
在我的例子中,我保留了 logfile_backup 值 3 和 maxbytes 10000000 因为我需要这个,我希望能帮助别人。