Heroku:在日志中看到params和sql活动? [英] Heroku: see params and sql activity in logs?

查看:105
本文介绍了Heroku:在日志中看到params和sql活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在服务器上查看我的heroku日志(使用 heroku logs --tail --app myapp )时,我看到如下所示:

When i view my heroku logs on the server (with heroku logs --tail --app myapp) i see something like this:

2011-06-21T14:09:25+00:00 app[web.1]: Started PUT "/reports/19.xml" for 77.89.149.137 at 2011-06-21 07:09:25 -0700
2011-06-21T14:09:25+00:00 heroku[router]: PUT myapp.heroku.com/reports/19.xml dyno=web.1 queue=0 wait=0ms service=7ms status=401 bytes=28
2011-06-21T14:09:26+00:00 heroku[nginx]: PUT /reports/19.xml HTTP/1.1 | 77.89.149.137 | 656 | http | 401

在我的本地日志中,我会看到类似这样的内容:

While in my local log i'd see something like this:

Started PUT "/reports/19" for 127.0.0.1 at 2011-06-21 15:27:01 +0100
  Processing by ReportsController#update as XML
  Parameters: {"report"=>{"workflow_status"=>"3"}, "id"=>"19"}
  Person Load (0.9ms)  SELECT "people".* FROM "people" WHERE "people"."email" = 'madeupemai@lkklj.com' LIMIT 1
  Report Load (0.4ms)  SELECT "reports".* FROM "reports" WHERE "reports"."id" = 19 LIMIT 1
DEPRECATION WARNING: Object#returning has been deprecated in favor of Object#tap. (called from update_report at /home/max/work/rails_apps/flamingo_container/flamingo/vendor/plugins/resource_this/lib/resource_this.rb:135)
Creating scope :open. Overwriting existing method Task.open.
  Task Load (2.0ms)  SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = 14 LIMIT 1
Completed 200 OK in 1648ms (Views: 568.2ms | ActiveRecord: 3.2ms)

即有更多的信息,特别是参数,来自路由器的信息,生成的sql,任何模板呈现等等等。

Ie with a lot more information, particularly the params, info from the router, generated sql, any templates rendered etc etc.

有谁知道我如何让我的英雄日志像我的开发一样冗长?我已经完成了以下工作:

Does anyone know how i can get my heroku log to be as verbose as my development one? I've done the following already:

1)在相关的(rails 3)环境文件中设置日志级别:

1) Set the log level in the relevant (rails 3) environment file:

config.log_level = :debug



<2>如 http://devcenter.heroku.com/articles/logging 中所述,告诉heroku使用不同的记录器级别。

2) Told heroku to use a different logger level, as described on http://devcenter.heroku.com/articles/logging

heroku config:add LOG_LEVEL=DEBUG --app myapp #from CLI

没有任何区别...任何人都有想法?

谢谢,max

Neither has made any difference...any ideas anyone?
thanks, max

推荐答案

你基本上想要在Heroku日志中显示SQL / params输出。您可以通过将以下所示的行添加到 production.rb 文件中的 config 块来完成此操作:

You're essentially wanting to show the SQL / params output in the Heroku logs. You can do this by adding the line shown below to the config block within your production.rb file:

MyAppNameHere::Application.configure do

  # add this line
  config.logger = Logger.new(STDOUT)

end

顺便说一下,设置日志级别调试只是意味着当您在Heroku上时 Rails.logger.debug 将输出到日志中

By the way, setting the log level to debug just means that Rails.logger.debug will output to the logs when you're on Heroku

这篇关于Heroku:在日志中看到params和sql活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆