Rails (specifically, Rails 6) defines ActiveSupport::Logger, which seems to be a wrapper of (one of Ruby's standard libraries) Logger according to the docs and source.
However, in the current official Rails reference as of October 2020 for Rails 6.0, the standard Logger is used in a config file. (It used to be ActiveSupport::Logger, maybe?)
Now, I would like to specify a different filename of the logfile from the default (log/development.log
in the development environment) in the config file (e.g., config/environments/development.rb
). Does
config.logger = Logger.new('log/my_log_file.log')
suffice? Or, is it better to use ActiveSupport::Logger? If so, what is the difference?
Note that in the default config/environments/development.rb
no setting to follow or modify is defined about the logfile name. Still, log/development.log
is created automatically in the development environment, so it must be defined somewhere obscure.
[EDIT] This answer suggests the way I put. I confirm it seems to work in my environment. But there is no reasoning why so… ActiveSupport::Logger is wrong?
ActiveSupport::Logger
adds some conveniences on top ofLogger
. For example, temporary silencing of the logger or broadcasting to multiple loggers. If you don't need these features, I think the standardLogger
should work just fine and without the overhead.ActiveSupport::Logger
is indeed a wrapper. Would you write it as an answer, perhaps with relevant references, maybe?