From e09b3d1c1d4a972c4f5dc0d36b291fa0f62fc201 Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Thu, 16 Jan 2025 13:55:37 -0800 Subject: [PATCH] Normalize logging to production.log file --- config/environments/production.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index cff57a5c6..181361064 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -40,10 +40,12 @@ # Skip http-to-https redirect for the default health check endpoint. # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new($stdout) - .tap { |logger| logger.formatter = Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } + # Log to STDOUT if env var is set + if ENV['RAILS_LOG_TO_STDOUT'].present? + logger = ActiveSupport::Logger.new($stdout) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end # Prepend all log lines with the following tags. config.log_tags = [:request_id]