1

我在rails 6中使用log4r时,报如下错误

这是完整的错误信息

.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.2/lib/active_support/tagged_logging.rb:22:in `call': wrong number of arguments (given 0, expected 4) (ArgumentError)
4

1 回答 1

1

配置/初始化程序/log4r_patch.rb

class Log4r::Logger
  def formatter()
    Proc.new{|severity, time, progname, msg|
      formatted_severity = sprintf("%-5s",severity.to_s)
      formatted_time = time.strftime("%Y-%m-%d %H:%M:%S")
      "[#{formatted_severity} #{formatted_time} #{$$}]\n #{msg}\n"
    }
  end
  def formatter=(temp)
  end
end

参考:https ://www.thegreatcodeadventure.com/building-a-custom-logger-in-rails/

于 2020-09-07T07:02:53.993 回答