I can't remember the last time I needed to open/read log/development.log
or log/test.log
.
These files usualy just consume disk space unnecessarily (some test.log
files can easily reach more than 1 GB).
After talking to some other developers, all of them agreed they don't use it as well.
So what I've been doing in my projects is adding the following code (note that it'll still display logs through the STDOUT
though):
Rails 4+
config/environments/development.rb
:
ruby
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
config/environments/test.rb
:
ruby
config.log_level = :warn
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
Rails 3
config/environments/development.rb
:
ruby
logger = ::Logger.new(STDOUT)
config.logger = ActiveSupport::TaggedLogging.new(logger)
config.active_support.deprecation = :stderr
config/environments/test.rb
:
ruby
config.log_level = :warn
logger = ::Logger.new(STDOUT)
config.logger = ActiveSupport::TaggedLogging.new(logger)
Post atualizado em 02/10/2017, 10:00:00
💬 Comentários desativados temporariamente. Desculpe pelo inconveniente.