简体   繁体   English

即使将log_level设置为:debug,rails 4.2也无法在heroku日志中看到数据库查询

[英]rails 4.2 can't see db queries in heroku logs even though log_level set to :debug

Here is a project I'm working on: https://github.com/homanchou/the_drawing_challenge 这是我正在从事的项目: https : //github.com/homanchou/the_drawing_challenge

I'm having trouble seeing any db queries in the server logs on heroku or even locally in the terminal when running Puma with Foreman. 使用Foreman运行Puma时,无法在heroku或什至在终端本地查看服务器日志中的任何数据库查询。

All I see are asset or web requests 我所看到的只是资产或网络请求

21:54:34 web.1  | started with pid 54784
21:54:35 web.1  | [54784] Puma starting in cluster mode...
21:54:35 web.1  | [54784] * Version 2.10.2 (ruby 2.1.5-p273), codename: Robots on Comets
21:54:35 web.1  | [54784] * Min threads: 1, max threads: 4
21:54:35 web.1  | [54784] * Environment: development
21:54:35 web.1  | [54784] * Process workers: 2
21:54:35 web.1  | [54784] * Preloading application
21:54:36 web.1  | [54784] * Listening on tcp://0.0.0.0:5000
21:54:36 web.1  | [54784] Use Ctrl-C to stop
21:54:36 web.1  | [54784] - Worker 0 (pid: 54785) booted, phase: 0
21:54:36 web.1  | [54784] - Worker 1 (pid: 54786) booted, phase: 0
21:54:43 web.1  | [54785] 127.0.0.1 - - [02/Apr/2015:21:54:43 -0700] "GET / HTTP/1.1" 200 - 0.3120
21:54:43 web.1  | [54785] 127.0.0.1 - - [02/Apr/2015:21:54:43 -0700] "GET /logo_header.png HTTP/1.1" 304 - 0.0079
21:54:45 web.1  | [54785] 127.0.0.1 - - [02/Apr/2015:21:54:45 -0700] "GET /challenges/8 HTTP/1.1" 200 - 0.0443
21:54:45 web.1  | [54785] 127.0.0.1 - - [02/Apr/2015:21:54:45 -0700] "GET /logo_header.png HTTP/1.1" 304 - 0.0067

I had to add another line to the Procfile log: tail -f -n 0 log/development.log to see logs or errors in stdout of foreman start like I normally do, but that only works locally and not on heroku unless I want to scale up a process for that tailing. 我必须在Procfile log: tail -f -n 0 log/development.log添加另一行log: tail -f -n 0 log/development.log来像通常那样查看foreman start标准输出中的日志或错误,但是它只能在本地运行,而不能在heroku上运行,除非我想要扩大拖尾的过程。

In my other rails project I can see the db queries fine, even on heroku I can see the db queries in the log: 在我的其他Rails项目中,我可以看到数据库查询很好,即使在heroku上,我也可以在日志中看到数据库查询:

2015-04-03T03:46:40.052067+00:00 app[web.1]: Started GET "/api/notifications/unread_count" for 97.93.34.8 at 2015-04-03 03:46:40 +0000
2015-04-03T03:46:40.070865+00:00 app[web.1]:   Merchant Load (2.7ms)  SELECT  "merchants".* FROM "merchants" WHERE "merchants"."id" = $1  ORDER BY "merchants"."id" ASC LIMIT 1  [["id", 7502]]
2015-04-03T03:46:40.085454+00:00 app[web.1]:   SQL (2.3ms)  UPDATE "merchants" SET "updated_at" = '2015-04-03 03:46:40.074442', "last_active_at" = '2015-04-03 03:46:40.074442' WHERE "merchants"."id" = $1  [["id", 7502]]
2015-04-03T03:46:40.101382+00:00 app[web.1]:    (2.3ms)  SELECT COUNT(*) FROM "notifications" WHERE "notifications"."merchant_id" = $1 AND "notifications"."state" = $2  [["merchant_id", 7502], ["state", "unread"]]
2015-04-03T03:46:40.058083+00:00 app[web.1]: Processing by NotificationsController#unread_count as JSON
2015-04-03T03:46:40.073916+00:00 app[web.1]:    (1.0ms)  BEGIN
2015-04-03T03:46:40.093737+00:00 app[web.1]:    (7.4ms)  COMMIT
2015-04-03T03:46:40.102858+00:00 app[web.1]: Completed 200 OK in 45ms (Views: 0.2ms | ActiveRecord: 15.6ms)

I tried comparing the two and even copying over some environment configurations but I still can't figure it out. 我尝试将两者进行比较,甚至在某些环境配置中进行复制,但仍然无法弄清楚。 I've tried setting config.log_level = :debug on the production environment. 我尝试在生产环境中设置config.log_level =:debug。 I can see db queries in the ruby console, but not the heroku or local puma stdout in the terminal. 我可以在ruby控制台中看到数据库查询,但是在终端中看不到heroku或本地puma标准输出。 What am I missing? 我想念什么?

If you need to use puma for websockets etc try adding 如果您需要将puma用于websockets等,请尝试添加

ActiveRecord::Base.logger.level = Logger::DEBUG

to your environments.rb or environments/production 到您的environment.rb或环境/生产

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该在我的Rails应用程序中使用log_level:debug in production - Should I use log_level :debug in production on my Rails app Rails 4日志级别重置为Debug,即使在生产中 - Rails 4 log level resets to Debug, even in production 如何为资产:预编译任务设置log_level? - How to set log_level for the assets:precompile task? Rails控制器参数为空,即使我可以在调试输出中看到它们 - Rails controller params are null, even though I can see them in debug output Heroku在我的Ruby on Rails应用程序中找不到文件 - 即使它们就在那里? - Heroku can't find files in my Ruby on Rails app - even though they are right there? 即使我能看到它们,也不能使用 rails 参数。 具体charge_id - Can't use rails params even though I can see them. Specifically charge_id Rails 5和Heroku:不能做“ heroku运行rake db:migrate” - Rails 5 and Heroku: can't do “heroku run rake db:migrate” 如何在heroku服务器日志上查看我的数据库事务查询(sql查询)? - How can see my database transaction queries (sql queries) on a heroku server log? 即使电子邮件位于数据库中,Devise也无法通过电子邮件找到用户? - Devise can't find user by email even though email is in DB? 从Rails的日志中过滤缓存的数据库查询? - Filter cached DB queries from Rails' logs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM