logging - Ruby: Logger and Daemons -
i'm using ruby 1.9.2p180 (2011-02-18 revision 30909)
in order logging utilize logging gem. programme has 2 blocks, used daemons.
but logging these blocks results in error , nil written logfile:
log shifting failed. closed stream log writing failed. closed stream
here happens in code:
log = logger.new(logbase + 'logfile.log', 'monthly') log.level = logger::info proc = daemons.call(options) # [...] log.info "any logmessage" # [...] end
any idea, whats wrong there?
the daemons
gem closes file descriptors when daemonizes process. logfiles opened before daemons block closed within forked process.
and since can't write closed file descriptors -> errors.
you can read more happens when daemonize process reading chapter:
what daemons internally daemons? http://daemons.rubyforge.org/daemons.html
the solution open logfile within daemon block instead of outside of it. should prepare it. note daemonizing changes working directory /
, take business relationship when referencing logfile paths.
ruby logging daemons
No comments:
Post a Comment