LoginSignup
3
3

More than 5 years have passed since last update.

ロギングエージェントでGCEからStackDriverにRailsのアプリログを送る(カスタムログ設定)

Posted at

概要

  • railsのアプリログをstackdriverに送りたい
  • Gemを使った方法がうまくいかなかった
  • fluentdの設定追加であっさりできたので困ったらこっちのほうがいいよ

やりかた

1. Gem使う

  • 公式のRuby 用 Stackdriver Logging の設定で設定する
  • 一般的にはこっちのが楽だと思う。
  • このgemいれてUnicorn起動するとレスポンスが返ってこなくなる現象が解決できず諦めた

2. ロギングエージェント(fluentd)のカスタム設定する

  • 今回はこっちを採用した

fluentdの設定追加方法

<source>
  @type tail
  format none
  path /var/www/rails_project/log/app.log # 送信したいログのpath
  pos_file /var/lib/google-fluentd/pos/your_project_app_log.pos #posファイルの設定。1source設定に対し1pos_fileを設定。1pos_fileに複数source設定するとこけた。 
  read_from_head true
  tag your_project_app_tag # logのタグ名。stackdriverから見えるやつ。
</source>
  • fluentdをreloadする
sudo service google-fluentd reload
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3