Log4r::Logger.new("log4r") results in a stack error if you add a rolling file outputter
Opened this issue · 1 comments
This one's exciting:
filename = '/tmp/testme'
logger = Log4r::Logger.new("log4r")
outputter = Log4r::RollingFileOutputter.new("foo", :filename => filename, :maxtime => 10)
logger.outputters = outputter
# (wait patiently with some logging)
sleep 20
logger.warn("foo")
This is exciting because in rollingfileoutputter.rb , when checking whether a roll is needed, we log that a roll is needed. that log checks that a roll is needed, and so logs that the roll is needed (and so on, ad infinitum).
This results in a SystemStackError, like so:
/usr/lib/ruby/1.8/monitor.rb:240:in `synchronize': stack level too deep (SystemStackError)
from /usr/lib/ruby/1.8/log4r/repository.rb:36:in `[]'
from /usr/lib/ruby/1.8/log4r/staticlogger.rb:15:in `[]'
from /usr/lib/ruby/1.8/log4r/staticlogger.rb:44:in `log_internal'
from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:169:in `requiresRoll'
from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:129:in `write'
from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:110:in `canonical_log'
from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:130:in `synch'
from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
... 3431 levels...
It seems to go log_internal -> requiresRoll -> logInternal -> requireRoll, ad infinitum.
There's scope for calling this a configuration error, but nowhere in the documentation does it state that the rolling file outputter shouldn't be used for the log4r internal logger...
/Nick
This one IS exciting!
Thanks for reporting it :)
- Colby
On Jan 11, 2012, at 5:32 AM, Nick Thomas wrote:
This one's exciting:
filename = '/tmp/testme'
logger = Log4r::Logger.new("log4r")
outputter = NonWarningFileOutputter.new("foo", :filename => filename, :maxtime => 10)
logger.outputters = outputter
this is exciting because in rollingfileoutputter.rb , when checking whether a roll is needed, we log that a roll is needed. that log checks that a roll is needed, and so logs that the roll is needed (and so on, ad infinitum).
This results in a SystemStackError, like so:
/usr/lib/ruby/1.8/monitor.rb:240:in
synchronize': stack level too deep (SystemStackError) from /usr/lib/ruby/1.8/log4r/repository.rb:36:in
[]'
from /usr/lib/ruby/1.8/log4r/staticlogger.rb:15:in[]' from /usr/lib/ruby/1.8/log4r/staticlogger.rb:44:in
log_internal'
from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:169:inrequiresRoll' from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:129:in
write'
from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:110:incanonical_log' from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:130:in
synch'
from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
... 3431 levels...It seems to go log_internal -> requiresRoll -> logInternal -> requireRoll, ad infinitum.
There's scope for calling this a configuration error, but nowhere in the documentation does it state that the rolling file outputter shouldn't be used for the log4r internal logger...
/Nick
Reply to this email directly or view it on GitHub:
#6