When I'm setting logging parameters to the Daemons (1.1.0) gem, how would I achieve similar behavior to this line?
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. It redirects STDOUT
and STDERR
directly to a file.
You can see the details of how the redirection works here: 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.
If this is not acceptable, I would suggest using Logger
directly like you provided in the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With