我找到了方法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