rails 日志摘要 gem

summaries of rails log with lograge gem

我正在使用 ELK 堆栈,我需要将我的 rails 日志发布到 logstash 服务器。我发现一些 gem 可以做到这一点,例如:

lograge总结rails日志

但是当我使用 lograge 时,日志结果是:full log + summarize log like:

Connecting to database specified by database.yml
Connecting to database specified by database.yml
{"@source":"unknown","@tags":[],"@fields":{},"method":"GET","path":"/","format":"html","controller":"home/summaries","action":"index","status":0,"duration":6.85,"product":"beesor-log","@timestamp":"2015-02-02T18:05:19.514583+00:00","@message":"[0] GET / (home/summaries#index)"}
{"@source":"unknown","@tags":[],"@fields":{},"method":"GET","path":"/login","format":"html","controller":"devise/sessions","action":"new","status":200,"duration":155.42,"view":87.71,"db":8.29,"product":"beesor-log","@timestamp":"2015-02-02T18:05:19.850720+00:00","@message":"[200] GET /login (devise/sessions#new)"}
Served asset /final_calls-b2b9d4899d488cafd9cbf55362f51edd.js - 200 OK (0ms)
Served asset /i18n-a014c1078d4f5a62e1459afd80ef048b.js - 200 OK (0ms)
Served asset /login-6e9b4528e684cf7f6bc276da58753af0.css - 200 OK (0ms)
Served asset /devise/sessions - 200 OK (0ms)
  [1m[36mUser Load (2.2ms)[0m  [1mSELECT "users".* FROM "users" WHERE "users"."username" = 'tenant_admin' AND "users"."status" = 'enabled' LIMIT 1[0m
  [1m[35m (1.0ms)[0m  BEGIN
  [1m[36m (1.4ms)[0m  [1mUPDATE "users" SET "last_sign_in_at" = '2015-02-02 17:03:35.791483', "current_sign_in_at" = '2015-02-02 18:05:25.525736', "sign_in_count" = 8, "updated_at" = '2015-02-02 18:05:25.528094' WHERE "users"."id" = 1[0m
  [1m[35m (13.9ms)[0m  COMMIT
  [1m[36m (0.8ms)[0m  [1mBEGIN[0m
  [1m[35m (1.2ms)[0m  UPDATE "users" SET "unique_session_id" = 'jyzQTvsZKJiTye1a5RFQ', "updated_at" = '2015-02-02 18:05:25.546695' WHERE "users"."id" = 1
  [1m[36m (4.4ms)[0m  [1mCOMMIT[0m
{"@source":"unknown","@tags":[],"@fields":{},"method":"POST","path":"/login","format":"html","controller":"devise/sessions","action":"create","status":302,"duration":141.81,"view":0.0,"db":0.0,"location":"http://localhost:3000/","product":"beesor-log","@timestamp":"2015-02-02T18:05:25.567320+00:00","@message":"[302] POST /login (devise/sessions#create)"}

这种行为正常吗?我了解到,使用此 gems,rails 日志结果将是:汇总日志,如:

{"@source":"unknown","@tags":[],"@fields":{},"method":"GET","path":"/","format":"html","controller":"home/summaries","action":"index","status":0,"duration":6.85,"product":"beesor-log","@timestamp":"2015-02-02T18:05:19.514583+00:00","@message":"[0] GET / (home/summaries#index)"} 
{"@source":"unknown","@tags":[],"@fields":{},"method":"GET","path":"/login","format":"html","controller":"devise/sessions","action":"new","status":200,"duration":155.42,"view":87.71,"db":8.29,"product":"beesor-log","@timestamp":"2015-02-02T18:05:19.850720+00:00","@message":"[200] GET /login (devise/sessions#new)"} 
{"@source":"unknown","@tags":[],"@fields":{},"method":"POST","path":"/login","format":"html","controller":"devise/sessions","action":"create","status":302,"duration":141.81,"view":0.0,"db":0.0,"location":"http://localhost:3000/","product":"beesor-log","@timestamp":"2015-02-02T18:05:25.567320+00:00","@message":"[302] POST /login (devise/sessions#create)"}

有人知道用 lograge 只发布 rails 日志摘要的方法吗?

正如所说 pxlpnk on issue 108 它在我的环境中设置的解决方案这条线:

config.assets.debug = false