Search code examples
ruby-on-railsloggingproduction

Rails 4 - Production enviroment just writing one line in production.log


I want to get the errors in production.log, but i have only one line that is:

# Logfile created on 2016-09-06 11:44:55 -0500 by logger.rb/47272

My configuration en production.rb about logs is:

  config.logger = Logger.new(STDOUT)
  config.log_level = :debug
  RAILS_DEFAULT_LOGGER = Logger.new('log/production.log')

What's wrong in my code?


Solution

  • Per Debugging Rails Applications, you want something like this:

    Rails.logger     = Logger.new 'log/production.log'
    config.log_level = :debug
    

    You can also set Rails.logger.level from the console, but I recommend setting your log file and log level in an initializer such as config/application.rb unless you're actively trying to debug a running instance in production. Debugging in production is not a DevOps best-practice, so I'd avoid that if at all possible.