6

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
    }
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Tommy
  • 1,809
  • 2
  • 13
  • 13

1 Answers1

3

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.

eric
  • 1,168
  • 8
  • 18