How can I make each unicorn worker of my Rails application writting in a different log file ?
The why : problem of mixed log files... In its default configuration, R
add this code to after_fork in unicorn.rb:
#one log per unicorn worker
if log = Rails.logger.instance_values['log']
ext = File.extname log.path
new_path =log.path.gsub %r{(.*)(#{Regexp.escape ext})}, "\\1.#{worker.nr}\\2"
Rails.logger.instance_eval do
@log.close
@log= open_log new_path, 'a+'
end
end