我在 Heroku 上部署了一个 Rails 应用程序工作正常,但是当我得到 500 时,我无法知道原因,因为 Heroku 日志 --tail 没有显示完整的错误消息。
我刚刚犯了一个虚拟的 500 错误
def puts_user_info
email = user.first.email
return render json: {data: email}, status: :ok
end
在本地开发上我得到undefined local variable or method 'user'了很好但在heroku日志上我刚刚得到
2021-07-08T08:47:38.948711+00:00 heroku[router]: at=info method=GET path="//customer_app/api/v1/puts/user/info" host=eaterybook-backend-staging.herokuapp.com request_id=6e224c0a-d874-45c4-882f-b5b0f1030972 fwd="119.155.23.119" dyno=web.1 connect=1ms service=920ms status=500 bytes=243 protocol=https
在我的 gemlist 中,我安装了 gem rails_12factor,在我的 production.rb 中我有
config.log_level = :debug
config.log_tags = [:request_id]
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
在我的 heroku 配置变量中
LOG_LEVEL = DEBUG
RACK_ENV = production
RAILS_ENV = production
RAILS_LOG_LEVEL = DEBUG
RAILS_LOG_TO_STDOUT = enabled