Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Easily debug rake task
desc "switch rails logger to stdout"
task :verbose => [:environment] do
Rails.logger =
desc "switch rails logger log level to debug"
task :debug => [:environment, :verbose] do
Rails.logger.level = Logger::DEBUG
desc "switch rails logger log level to info"
task :info => [:environment, :verbose] do
Rails.logger.level = Logger::INFO
Copy link

jameslafa commented Jul 11, 2016

Add debug.rake in /lib/tasks/debug.rake.

Calling rake debug my_task switch automatically the log level to debug and output in the console.

Copy link

repoles commented Jan 9, 2020

Clever! Tks ;)

Copy link

gbs4ever commented Nov 6, 2020

very cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment