Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

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
    }
like image 463
Tommy Avatar asked Mar 30 '11 00:03

Tommy


1 Answers

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.

like image 170
eric Avatar answered Oct 15 '22 16:10

eric