LoginSignup
11
11

More than 5 years have passed since last update.

RailsログLTSV対応(LTSV Logger + UUID)

Last updated at Posted at 2014-02-12

概要

  • RailsログのLTSV対応するのに既存のgem使ってみた
  • 条件 : UUIDを出せること
  • 使ってみたのは
    1. ltsv-logger
    2. 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)
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)
11
11
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
11
11