A lot times when you run rake tasks it would be nice to get output from rails logger into STDOUT. The simplest way to do it is to create a new rake task that will redirect output to STDOUT.
desc "switch rails logger to stdout" task :verbose => [:environment] do Rails.logger = Logger.new(STDOUT) end desc "switch rails logger log level to debug" task :debug => [:environment, :verbose] do Rails.logger.level = Logger::DEBUG end
This way when you execute your rake task you can add verbose first to get stdout log messages or don’t include it to have messages sent to the default log file:
rake verbose [some_task]