Configure structured JSON logging

This configuration is emulating what we do in HEY.
This commit is contained in:
Mike Dalessio
2025-03-10 11:52:28 -04:00
parent 6f1d200316
commit 989600c590
3 changed files with 14 additions and 1 deletions
+2 -1
View File
@@ -28,9 +28,10 @@ gem "redcarpet"
gem "rouge"
gem "jbuilder"
# Telemetry
# Telemetry and logging
gem "sentry-ruby"
gem "sentry-rails"
gem "rails_structured_logging", bc: "rails-structured-logging"
group :development, :test do
gem "debug"
+9
View File
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/basecamp/rails-structured-logging
revision: 0c2d45dd98c92156cc419e75cdad2aa903290d82
specs:
rails_structured_logging (0.2.0)
json
rails (>= 6.0.0)
GIT
remote: https://github.com/rails/rails.git
revision: 5520bd835e3724ffafe3f719f9aafe951567f2f3
@@ -420,6 +428,7 @@ DEPENDENCIES
propshaft
puma (>= 5.0)
rails!
rails_structured_logging!
redcarpet
rouge
rqrcode
+3
View File
@@ -50,6 +50,9 @@ Rails.application.configure do
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Structured JSON logging
config.structured_logging.logger = ActiveSupport::Logger.new(STDOUT)
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]