Created
December 13, 2012 00:14
-
-
Save freegenie/4272930 to your computer and use it in GitHub Desktop.
Unicorn after_fork block to have Rails write logs to a separare file for each worker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after_fork do |server, worker| | |
log_path = Rails.root.join('log',"#{Rails.env}.#{worker.nr}.log") | |
new_logger = Logger.new(log_path) | |
new_logger.level = Logger::INFO | |
Rails.logger.flush | |
Rails.logger.close | |
Rails.logger = Rails.application.config.logger = ActiveSupport::TaggedLogging.new(new_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 | |
ActiveRecord::Base.establish_connection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, man!