How to get Rails.logger printing to the console/stdout when running rspec?

Viewed 127531

Same as title: How to get Rails.logger printing to the console/stdout when running rspec? Eg.

Rails.logger.info "I WANT this to go to console/stdout when rspec is running"
puts "Like how the puts function works"

I still want Rails.logger to go to log/test.log too.

6 Answers

I had similar problem in rails 5.0. My api/request specs did not output errors into console, but into log/test.log file. Other test types were outputting errors to console normally.

Changing config.action_dispatch.show_exceptions to false fixed the problem:

# config/environments/test.rb
config.action_dispatch.show_exceptions = false
Related