[英]Ruby Daemons log rotation
When I'm setting logging parameters to the Daemons (1.1.0) gem, how would I achieve similar behavior to this line? 当我将日志记录参数设置为Daemons(1.1.0)gem时,我将如何实现与此行相似的行为?
logger = Logger.new('foo.log', 10, 1024000)
Daemon options: 守护进程选项:
options = {
:ARGV => ['start'],
:dir_mode => :normal,
:dir => log_dir,
:multiple => false,
:ontop => false
:mode => :exec,
:backtrace => true,
:log_output => true
}
Unfortunately the Daemons gem does not use Logger. 不幸的是,Daemons gem不使用Logger。 It redirects
STDOUT
and STDERR
directly to a file. 它将
STDOUT
和STDERR
直接重定向到文件。
You can see the details of how the redirection works here: https://github.com/ghazel/daemons/blob/master/lib/daemons/daemonize.rb#L241-261 您可以在此处查看重定向的详细信息: https : //github.com/ghazel/daemons/blob/master/lib/daemons/daemonize.rb#L241-261
Because of this, you will have to use something like logrotate and restart the daemon if you want to do log file rotation. 因此,如果要进行日志文件轮换,则必须使用logrotate之类的东西并重新启动守护程序。
If this is not acceptable, I would suggest using Logger
directly like you provided in the question. 如果这是不可接受的,我建议您直接使用
Logger
,就像问题中提供的一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.