end
There are two things that are happening here, because of there the logManager.getLogger line is occurring, it’s creating the @log
instance
variable on the class object. Whereas the logme method is an
instance
method which is attempting to access the instance variable on the
initialized
TestClass object.
If you change this to:
class TestClass
def initialize @log = LogManager.getLogger(TestClass)
end
def logme
@log.info('Test the logging')
end
end
Then you will access the right @log in the right scope
R. Tyler C.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.