Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Unicorn after_fork block to have Rails write logs to a separare file for each worker.
after_fork do |server, worker|
log_path = Rails.root.join('log',"#{Rails.env}.#{}.log")
new_logger =
new_logger.level = Logger::INFO
Rails.logger = Rails.application.config.logger =
ActiveSupport::Dependencies.logger = Rails.logger
ActiveRecord::Base.logger = Rails.logger
ActionController::Base.logger = Rails.logger
ActionMailer::Base.logger = Rails.logger
Rails.cache.logger = Rails.logger

vjt commented Dec 18, 2012

Thanks, man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment