Capistrano: tail -f log

Want to tail a production log with Capistrano?

If you type Ctrl C, you get a load of warnings in your console. Here’s how to fix that:

desc “tail production log files” 

task :tail_logs, :roles => :app do

  trap(“INT”) { puts ‘Interupted’; exit 0; }

  run “tail -f #{shared_path}/log/production.log” do |channel, stream, data|

    puts  # for an extra line break before the host name

    puts “#{channel[:host]}: #{data}” 

    break if stream == :err



Leave a Reply

Your email address will not be published. Required fields are marked *