rake solr:tail for acts_as_solr query log

Written . Tagged Rake, Ruby, Ruby on Rails, acts_as_solr.

Here is a quick (and a bit dirty) Rake task to track the acts_as_solr built-in Jetty server log:

1
2
3
4
5
6
7
8
namespace :solr do

  desc 'Tails the Solr log'
  task :tail => :environment do
    system("tail", "-f", "#{RAILS_ROOT}/vendor/plugins/acts_as_solr/solr/tmp/jetty_#{RAILS_ENV}")
  end

end

If you put that in e.g. lib/tasks/solr_additions.rake, you can then do rake solr:tail to see the last couple of queries to the Solr server. The output will update as new queries come in (courtesy of tail -f); break out of it with ⌃C.