我正在使用ELK堆栈,我需要将我的rails日志发布到logstash服务器。我发现了一些宝石,例如:
lograge总结rails log
但是当我使用lograge时,日志结果是:完整日志 + 汇总日志,如:
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)"}
这种行为是正常的吗?我已经明白,使用这些宝石,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 log的摘要吗?