Further information here: https://github.com/rails/rails/issues/5388
The above answer did not clear the log lines after each request (Rails 3.2.18). Therefore, I used an initializer based on this post :
class NonInterleavedLoggingMiddleware def initialize(app, options = {}) @log = Rails.logger .instance_variable_get(:@logger) .instance_variable_get(:@log) .instance_variable_get(:@logdev) .instance_variable_get(:@dev) @log.sync = false @app = app end def call(env) @app.call(env) ensure @log.flush # Rails.logger.flush has no effect / is deprecated end end YourAppName::Application.config.middleware.insert_before(Rails::Rack::Logger, NonInterleavedLoggingMiddleware)
source share