fix: log formatting on production
This commit is contained in:
@@ -11,19 +11,17 @@ Rails.application.configure do
|
|||||||
# require 'syslog/logger'
|
# require 'syslog/logger'
|
||||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||||
|
|
||||||
MAX_LOG_MEGABYTES = 50
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||||
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
|
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'
|
require 'custom_log_formatter'
|
||||||
config.log_formatter = CustomLogFormatter.new
|
config.log_formatter = CustomLogFormatter.new
|
||||||
config.logger.formatter = config.log_formatter
|
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
|
# Eager load code on boot. This eager loads most of Rails and
|
||||||
# your application in memory, allowing both threaded web servers
|
# your application in memory, allowing both threaded web servers
|
||||||
# and those relying on copy on write to perform better.
|
# and those relying on copy on write to perform better.
|
||||||
@@ -98,9 +96,6 @@ Rails.application.configure do
|
|||||||
# Send deprecation notices to registered listeners.
|
# Send deprecation notices to registered listeners.
|
||||||
config.active_support.deprecation = :notify
|
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.
|
# Do not dump schema after migrations.
|
||||||
# config.active_record.dump_schema_after_migration = false
|
# config.active_record.dump_schema_after_migration = false
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user