why is my rails server logging everything twice?

前端 未结 4 1630
青春惊慌失措
青春惊慌失措 2021-02-07 01:45

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

相关标签:
4条回答
  • 2021-02-07 02:10

    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
    
    0 讨论(0)
  • 2021-02-07 02:12

    I had success with this in development.rb:

    config.logger = ActiveSupport::Logger.new('/dev/null')
    
    0 讨论(0)
  • 2021-02-07 02:17

    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
    
    0 讨论(0)
  • 2021-02-07 02:17

    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')

    0 讨论(0)
提交回复
热议问题