通常我可以写日志Logger
:
//abc.rb
require 'logger'
logger = Logger.new('foo.log')
$./abc.rb
但在Daemons
我得到一个权限错误:
//xyz.rb
require 'logger'
require 'daemons'
Daemons.run_proc('xyz') do
logger = Logger.new('foo.log')
end
$./xyz.rb
/home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:599:in `initialize': Permission denied - foo.log (Errno::EACCES)
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:599:in `open'
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:599:in `create_logfile'
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:594:in `open_logfile'
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:549:in `initialize'
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:314:in `new'
from /home/raincole/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:314:in `initialize'
我在同一个目录中以相同的身份运行abc.rb
并运行。xyz.rb
为什么一个日志不能像另一个日志一样?