John
John

Reputation: 1276

why is my rails server logging everything twice?

my rails server seems like it is logging everything twice, not sure what is going on here, what should I do to investigate this ?

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

Upvotes: 22

Views: 3861

Answers (4)

Sam Sabey
Sam Sabey

Reputation: 199

I had success with this in development.rb:

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

Upvotes: -2

Jakub K
Jakub K

Reputation: 1711

In my case this was caused by the rails_12factor gem. This gem adds the rails_stdout_logging gem which sends the logs to standard output. This can be useful in a production environment but not in development when Rails already does it by default.

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

The solution is to only add this gem in production:

gem 'rails_12factor', group: :production

Upvotes: 47

usha
usha

Reputation: 29349

Have a look at this issue

Try adding the following code to you 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

Upvotes: 10

MGrantley
MGrantley

Reputation: 41

Do you have your logger set to anything in either config/application.rb or config/environments/development.rb?

If nothing, try adding this line to config/environments/development.rb:

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

Upvotes: 1

Related Questions