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
on 2005-12-29 21:58
on 2005-12-29 22:04
Hi ! 2005/12/29, Gary Barlow <firstname.lastname@example.org>: > 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 !
on 2005-12-29 22:19
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