Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is my rails server logging everything twice?

Tags:

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 
like image 715
John Avatar asked Feb 21 '14 15:02

John


People also ask

Where are rails logs stored?

In a Rails app, logs are stored under the /log folder.

Is rails logger thread safe?

logger level is not thread safe. The main issue appears to be that Rails. logger is a singleton.

How do I check logs in Ruby on Rails?

2.2 Log Levels If you want to know the current log level, you can call the Rails. logger. level method. This is useful when you want to log under development or staging without flooding your production log with unnecessary information.


2 Answers

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 
like image 197
Jakub K Avatar answered Oct 25 '22 03:10

Jakub K


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 
like image 43
usha Avatar answered Oct 25 '22 04:10

usha