我找到了方法set_log in the documentation,我只是想不通它的语法。下面是我的尝试:如何更改aws-ruby日志位置?
require 'ruby-aws'
Amazon::Util::Logging.set_log('my.log')
NoMethodError: undefined method `set_log' for Amazon::Util::Logging:Module
我找到了方法set_log in the documentation,我只是想不通它的语法。下面是我的尝试:如何更改aws-ruby日志位置?
require 'ruby-aws'
Amazon::Util::Logging.set_log('my.log')
NoMethodError: undefined method `set_log' for Amazon::Util::Logging:Module
你可以看到亚马逊::的Util ::日志是一个模块,set_log是一个“公共实例方法”。因此,你需要
class NewClass
include Amazon::Util::Logging
def foo
set_log('file.txt')
log 'debug_message'
end
end
一个更简单的方法是添加这一行:
set_log( “的/ dev/null的”)
我试图部署的Ruby-on的时候就遇到了这个问题 - 使用'aws-ruby'给heroku的邮件网站(我得到了“Permission denied - ruby-aws.log”错误)。
要将日志文件位置从'ruby-aws.log'更改为'log/ruby-aws.log',我将以下内容添加到初始化程序中。确保在使用任何aws-ruby库之前调用它。注意“set_log ...”行上的更改。
module Amazon
module Util
module Logging
def log(str)
set_log 'log/ruby-aws.log' if @@AmazonLogger.nil?
@@AmazonLogger.debug str
end
end
end
end