gpt4 book ai didi

ruby-on-rails - Rails 应用程序日志中的重复输出

转载 作者:行者123 更新时间:2023-12-03 15:32:08 26 4
gpt4 key购买 nike

这是我的输出:

Cache read: views/c4f74176be2db099863b59e962270679
Cache read: views/c4f74176be2db099863b59e962270679
Read fragment views/c4f74176be2db099863b59e962270679 (0.3ms)
Read fragment views/c4f74176be2db099863b59e962270679 (0.3ms)
Rendered planners/new.html.erb within layouts/application (12.0ms)
Rendered planners/new.html.erb within layouts/application (12.0ms)
Rendered layouts/_nav_bar.html.erb (1.3ms)
Rendered layouts/_nav_bar.html.erb (1.3ms)
Rendered layouts/_footer_bar.html.erb (0.1ms)
Rendered layouts/_footer_bar.html.erb (0.1ms)
Completed 200 OK in 861ms (Views: 859.2ms | ActiveRecord: 0.7ms)
Completed 200 OK in 861ms (Views: 859.2ms | ActiveRecord: 0.7ms)

这是我的 gemfile:

source 'https://rubygems.org'
ruby '2.1.3'

gem 'rails', '4.2.0'
gem 'pg', '~> 0.18.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'paperclip', '~> 4.2.1'
gem 'faker', '~> 1.4.2'
gem "twitter-bootstrap-rails", '~> 3.2.0'
gem 'bootstrap_form', '~> 2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'unicorn', '~> 4.8.3'
gem "therubyracer", '~> 0.12.1'
gem "less-rails", '~> 2.6.0'
gem "rails_12factor", '~> 0.0.3'
gem 'aws-sdk', '~> 1.5.7'
gem 'omniauth-twitter', '~> 1.1.0'
gem 'figaro', '~> 1.1.0'
gem 'responders', '~> 2.1.0'
gem 'faraday', '< 0.9.0'
gem 'rest-client', '~> 1.7.3'
gem 'bootstrap-datepicker-rails'
gem "dalli"


group :development, :test do
gem 'simplecov', '~> 0.9.1'
gem 'pry', '~> 0.10.1'
gem 'pry-byebug'
gem "factory_girl_rails", '~> 4.0'
gem 'web-console', '~> 2.0'
gem 'spring', '~> 1.2.0'
gem 'capybara', '~> 2.4.4'
gem 'mocha', '~> 1.1.0'
gem 'launchy', '~> 2.4.3'
gem 'capybara_minitest_spec'
gem 'database_cleaner', '~> 1.4.0'
gem 'quiet_assets'
gem 'awesome_print', require: "ap"
gem 'vcr'
end

出于某种原因,我的输出加倍了,但它看起来只是输出加倍,而不是运行两次。我的 View 时间加载是相同的,所以看起来它只是一个 STDOUT double。这是怎么回事?

最佳答案

简答

限制 rails_12factor 仅用于生产:

gem "rails_12factor",           '~> 0.0.3', group: :production

长答案

命令 rails server 除了将日志发送到记录器之外,还将日志发送到标准输出。因此,如果您的记录器写入标准输出,每个条目将在终端上出现两次。

gem rails_12factor 将您的日志发送到标准输出。如果您在开发中使用它,并使用 rails server 启动您的环境,那么您会得到重复的日志。有关详细信息,请参阅此评论(及其线程):

不过还有一个最后的障碍:在生产环境中使用 Rails 控制台时,我仍然可以看到重复的 SQL 输出(虽然不是在服务器日志中)。这个问题还在 Rails issue tracker 上讨论,似乎还没有解决方案。见:

关于ruby-on-rails - Rails 应用程序日志中的重复输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29302818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com