使用lograge时缺少Rails请求日志

时间:2017-01-02 17:43:02

标签: ruby-on-rails-4 heroku

# config/environments/production.rb

config.log_level = :info
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
  request_params = event.payload[:params].except("controller", "action", "")
  { params: request_params, ip: event.payload[:ip], uid: event.payload[:user_id] }
end

这适用于后台工作人员。对于rails请求它会在一段时间后停止工作。

2017-01-02T17:05:56.318489+00:00 heroku[router]: at=info method=POST path="/comments/3297684/cheer"
2017-01-02T17:05:55.915014+00:00 heroku[router]: at=info method=GET path="/north-engine-crossfit/feed"
2017-01-02T17:05:56.576926+00:00 heroku[router]: at=info method=GET path="/notifications?"
2017-01-02T17:05:56.455991+00:00 heroku[router]: at=info method=GET path="/assets/fallback/thumb_default.png"
2017-01-02T17:05:56.620939+00:00 heroku[router]: at=info method=GET path="/events/2808332/comments"
2017-01-02T17:05:56.930687+00:00 heroku[router]: at=info method=GET path="/workouts/bar-work-and-some-rowing/results/new?event_id=2808133"
2017-01-02T17:05:57.136227+00:00 heroku[router]: at=info method=GET path="/tfw-helsinki/feed"
2017-01-02T17:05:57.862004+00:00 heroku[router]: at=info method=GET path="/gyms/crossfit-herttoniemi/widgets/info"
2017-01-02T17:05:58.012593+00:00 heroku[router]: at=info method=GET path="/workouts/results/new"
2017-01-02T17:05:57.875231+00:00 heroku[router]: at=info method=GET path="/api/v1/mobile/users/get_notifications_count.json?"
2017-01-02T17:05:58.385305+00:00 heroku[router]: at=info method=POST path="/comments/3297738/cheer"
2017-01-02T17:05:58.514149+00:00 heroku[router]: at=info method=GET path="/events/2808045/comments" 
2017-01-02T17:05:58.562364+00:00 heroku[router]: at=info method=GET path="/events/2809768/comments" 

如上所示,只有heroku [路由器]正在登录STDOUT。 Lograge不会记录任何内容,除非出现以下内容:

2017-01-02T17:05:56.302136+00:00 app[web.1]: ** [NewRelic][2017-01-02 17:05:56 +0000 web.1 (8)] WARN : Skipping RUM instrumentation. Unable to find <body> tag in first 50000 bytes of document.

如果我看一下后台工作人员的记录,我会得到很多很好的输出,如:

017-01-02T17:05:59.018898+00:00 app[worker.2]: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753844) RUNNING
2017-01-02T17:05:59.018913+00:00 app[worker.2]: 2017-01-02T17:05:59+0000: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753844) RUNNING
2017-01-02T17:05:59.035080+00:00 app[worker.2]: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753844) COMPLETED after 0.0161
2017-01-02T17:05:59.035145+00:00 app[worker.2]: 2017-01-02T17:05:59+0000: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753844) COMPLETED after 0.0161
2017-01-02T17:05:59.038990+00:00 app[worker.2]: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753845) RUNNING
2017-01-02T17:05:59.039046+00:00 app[worker.2]: 2017-01-02T17:05:59+0000: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753845) RUNNING
2017-01-02T17:05:59.054456+00:00 app[worker.2]: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753845) COMPLETED after 0.0153
2017-01-02T17:05:59.054508+00:00 app[worker.2]: 2017-01-02T17:05:59+0000: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] Job DeliverDeviceNotification (id=10753845) COMPLETED after 0.0153
2017-01-02T17:05:59.057328+00:00 app[worker.2]: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] 2 jobs processed at 46.3347 j/s, 0 failed
2017-01-02T17:05:59.057383+00:00 app[worker.2]: 2017-01-02T17:05:59+0000: [Worker(host:74f88e14-63db-431d-ab87-8c8a0e031866 pid:4)] 2 jobs processed at 46.3347 j/s, 0 failed

任何人都知道为什么请求记录无效?

0 个答案:

没有答案