colbygk/log4r — Issue #6: Log4r::Logger.new("log4r") results in a stack error if you add a rolling file outputter
Author: lupine
Created: 2012-01-11 13:32:26+00:00
State: open

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: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