Engine Yard Cloudを使っててrailsのproduction.logをちょっとしたフィルターかけてサッと見たい。(productionでのバグの原因究明などで)

production.logを探るのってEYCに限らず、機会が多いわりに面倒臭い。

$ scp deploy@app.kowabana.jp:/data/kowabana/shared/log/production* .
$ gzip -d production.log-*.gz
$ grep -r 'foo' .

とか。productionサーバーへのアクセス権がある人しか見れないのも手軽じゃない。

次からはこんなことしたくないのでEYCのlogentries addonを使ってみた。logentriesは無料でも使える範囲が大きいし、以前使ったことがあるので慣れているのでちょうどいい。

Getting started with Logentriesの通りに進めていき、下記のようにproduction.logを追加した。

diff --git a/cookbooks/le/recipes/configure.rb b/cookbooks/le/recipes/configure.rb
index 8a4432d..8225077 100644
--- a/cookbooks/le/recipes/configure.rb
+++ b/cookbooks/le/recipes/configure.rb
@@ -16,6 +16,7 @@ follow_paths = [
 ]
 (node[:applications] || []).each do |app_name, app_info|
   follow_paths << "/var/log/nginx/#{app_name}.access.log"
+  follow_paths << "/data/#{app_name}/shared/log/production.log"
 end

upload, applyしてからLogentriesのDashboardにアクセス。

自前でログサーバー作ってアレコレすると大変なので手軽で重宝しそうです。