简体   繁体   中英

Why do I get uninitialized constant Exchange::Logger (NameError)?

My application is giving me this error:

/usr/local/www/sl-exchange/lib/exchange.rb:25:in 'initialize': uninitialized constant Exchange::Logger (NameError).

What gem or file does Logger come from?

class Exchange

  attr_accessor :logger, :options 

  QUEUE_INTERVAL = 15
  MONTHLY_PROCESS_DAY = 1 
  MINUTE = 60 
  HOUR_IN_SECONDS = 60 * 60 

  def initialize()

    # Setup Logging
    self.logger = Logger.new(STDOUT) #<-- this line is giving me issues
            ...

I'm not sure I got what you mean, but if you're just asking about what to require, there at Ruby Doc you can see the Logger class is defined at logger.rb, so require 'logger' should do the trick.

Also, there's no need to use the self.logger method, you can just access the variable using @logger

@logger = Logger.new(STDOUT)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM