From 00cf3b206622a8312d7a8681ddbefffa3a15bc5d Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 31 May 2024 09:25:09 +0100 Subject: [PATCH 1/2] Don't set config.log_format in development This configuration value doesn't exist and therefore this has no effect. Rails Semantic Logger automatically uses the colour format by default anyway. --- config/environments/development.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index ec9eb9129e..1724bb4836 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -75,6 +75,5 @@ config.logger = ActiveSupport::Logger.new(config.paths["log"].first, 1, 50.megabytes) - config.log_format = :color config.semantic_logger.backtrace_level = :debug end From 17bde92ca49cdcc90bd4ef421748172a6bf64bbb Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 31 May 2024 09:25:52 +0100 Subject: [PATCH 2/2] Set Rails Semantic Logger format to JSON The configuration `log_format` doesn't exist and therefore it wasn't being used anywhere, instead we need to specify the logging format when we add the log appender. In production we want this to be a JSON log so it can be parsed by Logit. --- config/environments/production.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index e6ff7105a7..7550964e13 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -52,7 +52,6 @@ # Include generic and useful information about system operation, but avoid logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). config.log_level = :info - config.log_format = :json # Prepend all log lines with the following tags. config.log_tags = [:request_id] @@ -82,7 +81,8 @@ config.rails_semantic_logger.add_file_appender = false config.semantic_logger.add_appender( io: $stdout, - formatter: config.rails_semantic_logger.format, + level: config.log_level, + formatter: :json, ) end