From 23ec66e338fa3110223e285cbdb89af6c3b48088 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 5 Dec 2019 11:59:49 +0000 Subject: [PATCH 1/2] Add timestamp to Rails logger in staging and prod so that info in logs can be accurately compared with data in the DB --- config/environments/production.rb | 7 +++++-- config/environments/staging.rb | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index af72e56b7d..1b762a16d0 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -36,8 +36,11 @@ Openfoodnetwork::Application.configure do # See everything in the log (default is :info) config.log_level = :info - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # Configure logging + Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) + Rails.logger.formatter = Logger::Formatter.new + Rails.logger.datetime_format = "%Y-%m-%d %H:%M:%S" + config.logger = Rails.logger # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 936897b31b..15124d3441 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -36,8 +36,11 @@ Openfoodnetwork::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # Configure logging + Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) + Rails.logger.formatter = Logger::Formatter.new + Rails.logger.datetime_format = "%Y-%m-%d %H:%M:%S" + config.logger = Rails.logger # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i From bec73adc898071357e6ccd56e0774e57fd37cb5f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 8 Jan 2020 15:06:19 +1100 Subject: [PATCH 2/2] Restore file logging for custom format logger The new custom logger was directed to stdout instead of a file. --- config/environments/production.rb | 13 +++++++------ config/environments/staging.rb | 11 ++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 1b762a16d0..91ff62a3be 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -34,13 +34,14 @@ Openfoodnetwork::Application.configure do config.action_mailer.default_url_options = { protocol: 'https' } # See everything in the log (default is :info) - config.log_level = :info + # config.log_level = :debug - # Configure logging - Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) - Rails.logger.formatter = Logger::Formatter.new - Rails.logger.datetime_format = "%Y-%m-%d %H:%M:%S" - config.logger = Rails.logger + # Configure logging for Rails 3.2: + config.logger = ActiveSupport::TaggedLogging.new(Logger.new(Rails.root.join("log", "#{Rails.env}.log"))) + config.logger.formatter = Logger::Formatter.new + config.logger.datetime_format = "%Y-%m-%d %H:%M:%S" + # Once we get to Rails 4.0, we can replace the above with: + #config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" } # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 15124d3441..91ff62a3be 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -36,11 +36,12 @@ Openfoodnetwork::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug - # Configure logging - Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) - Rails.logger.formatter = Logger::Formatter.new - Rails.logger.datetime_format = "%Y-%m-%d %H:%M:%S" - config.logger = Rails.logger + # Configure logging for Rails 3.2: + config.logger = ActiveSupport::TaggedLogging.new(Logger.new(Rails.root.join("log", "#{Rails.env}.log"))) + config.logger.formatter = Logger::Formatter.new + config.logger.datetime_format = "%Y-%m-%d %H:%M:%S" + # Once we get to Rails 4.0, we can replace the above with: + #config.log_formatter = Logger::Formatter.new.tap { |f| f.datetime_format = "%Y-%m-%d %H:%M:%S" } # Use a different cache store in production memcached_value_max_megabytes = ENV.fetch("MEMCACHED_VALUE_MAX_MEGABYTES", 1).to_i