Topic: Logging error while running tests: closed stream

When running "rake test" I often receive following error when the tests have been running for some time:

Logger::ShiftingError: Shifting failed. closed stream

I know this error is thrown because my test.log file reached it's maximum size (which is configured in environmnt.rb). I think rails then closes this file, causing all tests running at that moment to fail.

Is there an elegant way to avoid this error?

My current solution is to create a rake tasks for testing, that first moves the current test.log to another file and creates a new empty test.log, but I'm not happy with that.

Here is a bigger stack trace:

Logger::ShiftingError: Shifting failed. closed stream
    D:/Apps/ruby-1.8.6-p398/lib/ruby/1.8/logger.rb:501:in `write'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/1.8/logger.rb:496:in `write'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/1.8/logger.rb:326:in `add'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/1.8/logger.rb:348:in `debug'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/proxy/create.rb:6:in `result'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:316:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:260:in `create'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/proxy/build.rb:17:in `associate'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/attribute/association.rb:15:in `add_to'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:313:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `each'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:260:in `create'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/proxy/build.rb:17:in `associate'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/attribute/association.rb:15:in `add_to'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:313:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `each'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:260:in `create'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/proxy/build.rb:17:in `associate'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/attribute/association.rb:15:in `add_to'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:313:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `each'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:311:in `run'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb:260:in `create'
    /test/functional/entity_controller_test.rb:9:in `setup'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/test-unit-1.2.3/lib/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/test-unit-1.2.3/lib/test/unit/ui/console/testrunner.rb:67:in `start_mediator'
    D:/Apps/ruby-1.8.6-p398/lib/ruby/gems/1.8/gems/test-unit-1.2.3/lib/test/unit/ui/console/testrunner.rb:41:in `start'