Browse Source

Pull Request #2637 - Add Rails 5 log to STDOUT env variable support (RAILS_LOG_TO_STDOUT). Huge thanks to @thegcat.

Thorsten Eckel 5 years ago
parent
commit
7a965d7385
1 changed files with 6 additions and 0 deletions
  1. 6 0
      config/environments/production.rb

+ 6 - 0
config/environments/production.rb

@@ -54,6 +54,12 @@ Rails.application.configure do
   # Use a different logger for distributed setups.
   # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
 
+  if ENV['RAILS_LOG_TO_STDOUT'].present?
+    logger           = ActiveSupport::Logger.new(STDOUT)
+    logger.formatter = config.log_formatter
+    config.logger    = ActiveSupport::TaggedLogging.new(logger)
+  end
+
   # Enable serving of images, stylesheets, and JavaScripts from an asset server.
   # config.action_controller.asset_host = 'http://assets.example.com'