I have a problem using Log4r.
uninitialized constant Log4r::Logger::RootLogger
I tried this, but still got an error:
>> require "log4r"
=> true
>> Log4r::DEBUG
NameError: uninitialized constant Log4r::DEBUG
>> Log4r::Logger.root
=> uninitialized constant Log4r::Logger::RootLogger
from /var/lib/gems/1.9.1/gems/log4r-1.1.11/lib/log4r/staticlogger.rb:5:in `root'
from (irb):5
from /usr/bin/irb:12:in `<main>'
Your problem with
Log4r::Logger.root
is version depending (the actual version 1.1.11 has this problem).You may use the previous log4r-version 1.1.10:
log4r defines the constants like
Log4r::DEBUG
with the creation of the first logger.You need a
Log4r::Logger.new('dummy')
before you have access to the level constants.Some background: There is a constant
Log4r::Log4rConfig::LogLevels
defining the different levels. The level-constants are defined, when the first logger is created. You may define them also withLog4r.define_levels(*Log4r::Log4rConfig::LogLevels)
This technique allows it to create loggers with different logging levels.