概要
- RailsログのLTSV対応するのに既存のgem使ってみた
- 条件 : UUIDを出せること
- 使ってみたのは
- ltsv-logger
- logger-ltsv
結論
- 非常に簡単に使える
- どちらもあまりメンテされてなさそう
- 色々やりたければ自前の方がいいかも
使ってみた
1 ltsv-logger
config/environments/development.rb
# ltsv-logger
config.log_tags = [ :uuid ]
config.logger = ActiveSupport::TaggedLogging.new(LTSV::Logger.open("log/development.log"))
- ログ出力例
time:2014-01-27 17:23:52 +0900 message:[8f72b641-edf2-4f6e-8484-fb3e3c471709] Started GET "/" for 127.0.0.1 at 2014-01-27 17:23:52 +0900
time:2014-01-27 17:23:52 +0900 message:[8f72b641-edf2-4f6e-8484-fb3e3c471709] ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
time:2014-01-27 17:23:52 +0900 message:[8f72b641-edf2-4f6e-8484-fb3e3c471709] Processing by LepusController#top as HTML
time:2014-01-27 17:23:52 +0900 message:[8f72b641-edf2-4f6e-8484-fb3e3c471709] Rendered lepus/top.html.erb within layouts/application (0.9ms)
time:2014-01-27 17:23:52 +0900 message:[8f72b641-edf2-4f6e-8484-fb3e3c471709] Completed 200 OK in 41ms (Views: 27.9ms | ActiveRecord: 0.0ms)
- logger-ltsv
- https://github.com/tnakamura/logger-ltsv
- http://tnakamura.hatenablog.com/entry/2013/05/04/173645
- 変更点
config/environments/development.rb
# logger-ltsv
config.log_tags = [ :uuid ]
config.logger = ActiveSupport::TaggedLogging.new(LTSVLogger.new("log/development.log"))
- ログ出力
severity:INFO datetime:2014-01-27 17:27:06 +0900 message:[4285dacb-16ec-484b-b73a-96b1dd4d7f05] Started GET "/" for 127.0.0.1 at 2014-01-27 17:27:06 +0900
severity:DEBUG datetime:2014-01-27 17:27:06 +0900 message:[4285dacb-16ec-484b-b73a-96b1dd4d7f05] ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
severity:INFO datetime:2014-01-27 17:27:06 +0900 message:[4285dacb-16ec-484b-b73a-96b1dd4d7f05] Processing by LepusController#top as HTML
severity:INFO datetime:2014-01-27 17:27:06 +0900 message:[4285dacb-16ec-484b-b73a-96b1dd4d7f05] Rendered lepus/top.html.erb within layouts/application (0.8ms)
severity:INFO datetime:2014-01-27 17:27:06 +0900 message:[4285dacb-16ec-484b-b73a-96b1dd4d7f05] Completed 200 OK in 41ms (Views: 27.5ms | ActiveRecord: 0.0ms)