我找到了方法set_log in the documentation,我无法弄清楚调用它的语法。这是我试过的:
require 'ruby-aws'
Amazon::Util::Logging.set_log('my.log')
NoMethodError: undefined method `set_log' for Amazon::Util::Logging:Module
答案 0 :(得分:1)
您可以看到Amazon :: Util :: Logging是一个模块,set_log是一个'公共实例方法'。所以你需要
class NewClass
include Amazon::Util::Logging
def foo
set_log('file.txt')
log 'debug_message'
end
end
答案 1 :(得分:1)
我在尝试部署使用'aws-ruby'到heroku的Ruby-on-Rails站点时遇到了这个问题(我得到了“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
答案 2 :(得分:0)
更简单的方法是添加此行:
set_log( “的/ dev /空”)