Access rails logger from plain class

How can I “get” the rails logger from a plain class, that is a class
that does not inherit from a rails class?

I have tried using RAILS_DEFAULT_LOGGER (see below) but it’s nil

class MyClass

logger = RAILS_DEFAULT_LOGGER

def myMethod
logger.debug(“stuff…”)
end

end

Hi !

2005/12/29, Gary B. [email protected]:

class MyClass

logger = RAILS_DEFAULT_LOGGER

def myMethod
logger.debug(“stuff…”)
end

end

In #myMethod, Ruby will resolve logger as a local variable, which is
nil. What you should do instead is:

class MyClass
def logger
RAILS_DEFAULT_LOGGER
end

def myMethod
logger.debug “stuff”
end
end

Hope that helps !

Thanks working now.

Another logger question
“HowtoAccessTheLogFile” on the RoR wiki shows RAILS_DEFAULT_LOGGER setup
in environment.rb but I can’t see it in my environment.rb. Has this
changed? I have rails v1.0