Why Rails doesn't write to development.log

Suddenly my Rails 4.2 application is not writing anything for development.log.

Absolutely nothing!

I tried to check the correct use of the environment, restart the server, check for gems that can interact with the registrar, check permissions, logger.flush and rake log:clean .

The log file is now completely empty and nothing is written.

Running rails s gives:

 => Booting WEBrick => Rails 4.2.0 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-03-14 18:49:57] INFO WEBrick 1.3.1 [2015-03-14 18:49:57] INFO ruby 2.1.5 (2014-11-13) [x86_64-darwin14.0] [2015-03-14 18:49:57] INFO WEBrick::HTTPServer#start: pid=3963 port=3000 

There are quite a few similar questions in Stackoverflow, but no one gives an answer that worked in my case.

I have no idea what can cause this and how to systematically debug it.

What steps should be taken?

+7
source share
4 answers

Well, after long walks in a circle, I finally found the culprit.

rails_12factor explicitly overwrites config.logger.

See: https://github.com/heroku/rails_stdout_logging/blob/master/lib/rails_stdout_logging/rails3.rb#L7

I removed this gem from the development environment (I really need it only in the deployed environment), and everything now works.

To run a gem only in production, it must be in the following group:

 # This is override development.log output and should only go in production. group :production do gem 'rails_12factor' end 

Thanks @maxd for helping me make me think in the right direction.

+22
source

I think your problem could be caused by the following things:

  • You set a high log level. Check the application.rb and environments\*.rb files:

     # Set to :debug to see everything in the log. config.log_level = :error 
  • You set up your own logging. Check application.rb , environments/*.rb and all files in initializers/*.rb :

     # Use a different logger for distributed setups. config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 

These two steps will help you investigate the problem and fix it.

+1
source

If in AWS (or similar) you need to make sure your log directory has write access.

0
source

Add the following line to config/environments/development.rb

 config.log_level = :debug 

restart the server

0
source

Source: https://habr.com/ru/post/1215344/


All Articles