如何关闭rails 4日志中的ANSI转义颜色代码

时间:2015-10-05 16:25:10

标签: ruby-on-rails-4 logging

在我的rails 4日志中,我得到了这样的垃圾记录:

^{[1m^{[36mPerson Load (0.7ms)^{[0m  ^{[1mSELECT  "people".* FROM "people" 
  WHERE "people"."id" = $1 LIMIT 1^{[0m  [["id", 673143]]

如何告诉导轨4关闭这种颜色?

我尝试将config.active_record.colorize_logging = false添加到config/application.rb,但我收到了此错误:

  

/home/sweerasinghe/trunk_1509171953/vendors/ruby-2.2.2/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `colorize_logging=' for ActiveRecord::Base:Class (NoMethodError)

1 个答案:

答案 0 :(得分:18)

你想要这个:

config.colorize_logging = false

这在Configurating Rails Applications Rails Guide的Rails General Configuration部分中有记录。