diff --git a/config/appsignal.yml b/config/appsignal.yml index ae39274c..520a8aae 100644 --- a/config/appsignal.yml +++ b/config/appsignal.yml @@ -29,8 +29,6 @@ default: &defaults # See https://docs.appsignal.com/ruby/configuration/options.html for # all configuration options. -log_path: "tmp/log" - # Configuration per environment, leave out an environment or set active # to false to not push metrics for that environment. development: diff --git a/config/environments/production.rb b/config/environments/production.rb index ecc8dbe6..3e514a43 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -55,12 +55,10 @@ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true - config.log_tags = [:request_id] - console_logger = ActiveSupport::Logger.new($stdout) + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new($stdout) .tap { |logger| logger.formatter = ::Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - appsignal_logger = ActiveSupport::TaggedLogging.new(Appsignal::Logger.new("rails")) - config.logger = ActiveSupport::BroadcastLogger.new(console_logger, appsignal_logger) # Prepend all log lines with the following tags. config.log_tags = [:request_id] diff --git a/config/initializers/logging.rb b/config/initializers/logging.rb new file mode 100644 index 00000000..eb47a824 --- /dev/null +++ b/config/initializers/logging.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +if Rails.env.production? + console_logger = ActiveSupport::Logger.new($stdout) + appsignal_logger = ActiveSupport::TaggedLogging.new(Appsignal::Logger.new("rails")) + Rails.logger = ActiveSupport::BroadcastLogger.new(console_logger, appsignal_logger) +end