在 Ruby on Rails(版本 6)应用程序中更改日志位置(即 `LogDevice`)

Change the log location (i.e., `LogDevice`) in a Ruby on Rails (version 6) application

Rails 3 似乎在配置中有一个 属性 用于更改 Rails.loggerconfig.log_path 的输出位置。这已被弃用。查看 Rails 6 应用程序,现在是这样做的方法吗?还是这个配置 属性 被移到了新的地方?

  logger           = ActiveSupport::Logger.new('log/blahblah.log')
  logger.formatter = config.log_formatter
  config.logger    = ActiveSupport::TaggedLogging.new(logger)

这样做就可以了:

config.paths['log'] = 'log/new_log_file.log'

您可以在此处阅读有关路径的更多信息: https://api.rubyonrails.org/classes/Rails/Application/Configuration.html#method-i-paths