brianegge
brianegge

Reputation: 29862

How do I change the aws-ruby log location?

I've found the method set_log in the documentation, I just can't figure out the syntax to call it. Here's what I tried:

require 'ruby-aws'
Amazon::Util::Logging.set_log('my.log')
NoMethodError: undefined method `set_log' for Amazon::Util::Logging:Module

Upvotes: 0

Views: 560

Answers (3)

Andrew DiMichele
Andrew DiMichele

Reputation: 11

I ran into this problem when trying to deploy a Ruby-on-Rails site that uses 'aws-ruby' to heroku (I got the "Permission denied - ruby-aws.log" error).

To change the log file location from 'ruby-aws.log' to 'log/ruby-aws.log', I added the following to an initializer. Make sure this is called before you use any of the aws-ruby library. Notice the change on the "set_log..." line.

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

Upvotes: 1

Steve Quezadas
Steve Quezadas

Reputation: 744

A simpler way would be to add this line:

set_log("/dev/null")

Upvotes: 0

andrykonchin
andrykonchin

Reputation: 2517

You can see that Amazon::Util::Logging is a module and set_log is a 'Public Instance method'. So you need

class NewClass
 include Amazon::Util::Logging

  def foo
    set_log('file.txt')
    log 'debug_message'
  end
end

Upvotes: 1

Related Questions