Monday, July 02, 2018

How to tail production log in Capistrano 3

1. Add:

to lib/capistrano/tasks/tail.rake.

namespace :logs do
  desc "tail rails logs. Usage cap production logs:tail_rails"
  task :tail_rails do
    on roles(:app) do
      execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
    end
  end
end

2. You can now tail the production log from your local machine:

cap production logs:tail_rails