Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2017 21:55
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mudge/5063930 to your computer and use it in GitHub Desktop.
Unicorn configuration for Rails 3.2 application to log to a different file per worker (to stop logs interleaving with one another).
after_fork do |server, worker|
# Override the default logger to use a separate log for each Unicorn worker.
Rails.logger = ActiveRecord::Base.logger = ActionController::Base.logger = begin
path = Rails.configuration.paths["log"].first
f =".log", "-#{}.log"), "a")
f.sync = true
logger =
logger.level = ActiveSupport::BufferedLogger.const_get(Rails.configuration.log_level.to_s.upcase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment