为什么我的rails服务器记录了两次?

时间:2014-02-21 15:14:29

标签: ruby-on-rails

我的rails服务器似乎记录了两次,不知道这里发生了什么,我应该怎么做才能调查这个?

enter image description here

my gemfile

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

gem 'rails', '4.0.1'
gem 'haml-rails'
gem 'pg', '~> 0.17.1'
gem 'redis'
gem 'redis-namespace'
gem 'thin', '~> 1.6.1'
gem 'rabl'
gem 'underscore-rails'

#assets
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'foundation-rails'
gem 'font-awesome-rails'

#javascript
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
gem 'angularjs-rails', '~> 1.2.7'
gem 'ngmin-rails', '~> 0.4.0'

#user auth
gem 'devise', '3.0.0'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'uuidtools'


#misc tools
gem 'twitter'

#heroku
gem 'rails_12factor'

group :development, :test do
  gem 'capybara-webkit', github: 'thoughtbot/capybara-webkit', branch: 'master'
  gem 'rspec-rails', '~> 2.14.1'
  gem 'factory_girl_rails', '4.2.1'
  gem 'mocha', '~> 1.0.0'
  gem 'pry'
  gem 'pry-debugger'
  gem 'quiet_assets'
  gem 'parallel_tests'
  gem 'zeus-parallel_tests'
  gem 'guard-rspec'
  gem 'rb-fsevent'
end

group :development do 
  gem 'guard-livereload'
  gem 'rack-livereload'
  gem 'better_errors'
  gem 'terminal-notifier-guard'
end

group :test do
  gem 'launchy', '>= 2.1.2'
  gem 'capybara', '>= 1.1.3'
  gem 'database_cleaner', '~> 1.2.0'
  gem 'zeus', :require => false
  gem 'shoulda-matchers'
  gem 'pdf-inspector'
  gem 'selenium-webdriver'
  gem "mock_redis", "~> 0.11.0"
end

4 个答案:

答案 0 :(得分:46)

在我的情况下,这是由rails_12factor宝石引起的。这个gem添加了rails_stdout_logging gem,它将日志发送到标准输出。这在生产环境中非常有用,但在Rails默认情况下不能在开发中使用。

https://github.com/heroku/rails_12factor#rails-4-logging

解决方案是仅在生产中添加此gem:

gem 'rails_12factor', group: :production

答案 1 :(得分:10)

看看这个issue

尝试将以下代码添加到config / application.rb

   if Rails.env.development?
        # Don't log to STDOUT, by default rails s will handle it
        config.logger = Logger.new('/dev/null')
    else
        # Don't log to file, sending everything to unicorn file.
        config.logger = Logger.new(STDOUT)
    end

答案 2 :(得分:1)

您是否在config / application.rb或config / environments / development.rb中将记录器设置为任何内容?

如果没有,请尝试将此行添加到config / environments / development.rb:

config.logger = Logger.new('/dev/null')

答案 3 :(得分:-2)

我在development.rb中取得了成功:

config.logger = ActiveSupport::Logger.new('/dev/null')