Rails 3.2.x: How to change logging levels without restarting the application

In Rails console, you can simply do:

Rails.logger.level = :debug

Now all executed code will run with this log level


Why don't you use operating system signals for that? For example on UNIX user1 and user2 signals are free to use for your application:

config/initializers/signals.rb:

trap('USR1') do
  Rails.logger.level = Logger::DEBUG
end

trap('USR2') do
  Rails.logger.level = Logger::WARN
end

Then just do this:

kill -SIGUSR1 pid
kill -SIGUSR2 pid

Just make sure you dont override signals of your server - each server leverages various signals for things like log rotation, child process killing and terminating and so on.