Use ActiveSupport::TaggedLogging.logger shorthand to set logger in production env (#34746)

This commit is contained in:
Matt Jankowski 2025-05-21 04:50:36 -04:00 committed by GitHub
parent 30ee67e2c6
commit 67f5122ba6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,17 +52,14 @@ Rails.application.configure do
}, },
} }
# Log to STDOUT by default # Use default logging formatter so that PID and timestamp are not suppressed.
config.logger = ActiveSupport::Logger.new($stdout) config.log_formatter = Logger::Formatter.new
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Prepend all log lines with the following tags. # Log to STDOUT with the current request id as a default log tag.
config.log_tags = [:request_id] config.log_tags = [:request_id]
config.logger = ActiveSupport::TaggedLogging.logger($stdout, formatter: config.log_formatter)
# "info" includes generic and useful information about system operation, but avoids logging too much # Change to "debug" to log everything (including potentially personally-identifiable information!)
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
# Use a different cache store in production. # Use a different cache store in production.
@ -90,9 +87,6 @@ Rails.application.configure do
# Don't log any deprecations. # Don't log any deprecations.
config.active_support.report_deprecations = false config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Better log formatting # Better log formatting
config.lograge.enabled = true config.lograge.enabled = true