Skip to content

Commit

Permalink
fix: log formatting on production
Browse files Browse the repository at this point in the history
  • Loading branch information
karolsojko committed Jul 8, 2020
1 parent 52696cd commit c96a6c9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

MAX_LOG_MEGABYTES = 50
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
else
MAX_LOG_MEGABYTES = 50
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
end

require 'custom_log_formatter'
config.log_formatter = CustomLogFormatter.new
config.logger.formatter = config.log_formatter

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
Expand Down Expand Up @@ -98,9 +96,6 @@
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Do not dump schema after migrations.
# config.active_record.dump_schema_after_migration = false
end

0 comments on commit c96a6c9

Please sign in to comment.