Skip to content

Commit

Permalink
Configure JSON logs in production
Browse files Browse the repository at this point in the history
This updates the configuration for Semantic Logger to output the JSON
logs to standard output, as per the instructions:

https://logger.rocketjob.io/rails.html#log-to-standard-out
  • Loading branch information
thomasleese committed Mar 21, 2024
1 parent 9083d67 commit 200b4b8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# 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]
Expand All @@ -77,9 +78,12 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
$stdout.sync = true
config.rails_semantic_logger.add_file_appender = false
config.semantic_logger.add_appender(
io: $stdout,
formatter: config.rails_semantic_logger.format,
)
end

# Do not dump schema after migrations.
Expand Down

0 comments on commit 200b4b8

Please sign in to comment.