我正在使用带有logstash-logger的lograge来登录Rails项目。 以下是我对记录器的配置:
config.log_level = :debug
config.lograge.enabled = true
config.lograge.keep_original_rails_log = false
config.lograge.formatter = Lograge::Formatters::Logstash.new
config.logger = LogStashLogger.new(type: :file, path: '/path/to/development.log', sync: true)
config.lograge.custom_options = lambda do |event|
{:log_type => "lograge", :timing => event.time, :params =>
event.payload[:params]}
end
但是,我经常会收到错误编码的消息,例如{"message":" \u001B[1m\u001B[36mRecord Load (0.5ms)\u001B[0m \u001B[1mSELECT \"record\".* FROM \"records\" WHERE \"videos\".\"id\" = '1511245' LIMIT 1\u001B[0m","@timestamp":"2017-08-07T11:22:50.180+08:00","@version":"1","severity":"DEBUG","host":"my_host"}
如何正确设置日志文件的编码?
答案 0 :(得分:0)
尝试在记录器配置的正上方添加config.colorize_logging = false
。