Reputation: 2801
We've been using unicorn to deploy our application. Everything went fine except for the production.log file, which turned out to be unreadable because the way unicorn was designed. Every instance of unicorn wrote to the same file, causing all the lines spaghetti'ed together.
So is there a way to tell the logger to log independently across multiple unicorn instances?
Upvotes: 2
Views: 908
Reputation: 2801
edit your unicorn.conf.rb
, and change the after_fork
block to something like:
after_fork do |server, worker|
filepath = "#{Rails.root}/log/#{Rails.env}.#{worker.nr}.log"
Rails.logger = Logger.new(filepath, File::WRONLY | File::APPEND)
ActiveSupport::LogSubscriber.logger = Rails.logger
ActionController::Base.logger = Rails.logger
ActionMailer::Base.logger = Rails.logger
ActiveResource::Base.logger = Rails.logger
end
Upvotes: 2