diff --git a/app/lib/audit_logger.rb b/app/lib/audit_logger.rb index 84c3442..788a6cc 100644 --- a/app/lib/audit_logger.rb +++ b/app/lib/audit_logger.rb @@ -1,6 +1,6 @@ class AuditLogger < ActiveSupport::Logger def initialize super(Config[:audit_log_file]) - self.formatter = AuditLogFormatter.new + self.formatter = JsonLogFormatter.new end end diff --git a/app/lib/audit_log_formatter.rb b/app/lib/json_log_formatter.rb similarity index 85% rename from app/lib/audit_log_formatter.rb rename to app/lib/json_log_formatter.rb index 0304ea4..5e759cd 100644 --- a/app/lib/audit_log_formatter.rb +++ b/app/lib/json_log_formatter.rb @@ -1,4 +1,4 @@ -class AuditLogFormatter < ActiveSupport::Logger::SimpleFormatter +class JsonLogFormatter < ActiveSupport::Logger::SimpleFormatter def call(severity, timestamp, _progname, message) # request_id is unique to the life of the api request request_id = Thread.current[:request_id] diff --git a/config/initializers/logging.rb b/config/initializers/logging.rb new file mode 100644 index 0000000..e6e15dd --- /dev/null +++ b/config/initializers/logging.rb @@ -0,0 +1,4 @@ +Rails.application.config.to_prepare do + Rails.logger = ActiveSupport::Logger.new(STDOUT) + Rails.logger.formatter = JsonLogFormatter.new +end