Search code examples
ruby-on-railsrubyloggingprivacy

Is there a way to stop rails logging everything?


I don't want it to log incoming IPs, I don't want it to log any internal happenings.
I just want Rails to process the requests as they come in and that's that.

Is this possible to do?

How can I prevent having a growing development.log or production.log?


Solution

  • You could just replace the Rails logging facilities with loggers that log to /dev/null:

    class NullLoggerRailtie < Rails::Railtie
      initializer 'null_logger', :before => 'initialize_logger' do |app|
        Rails.logger = ActiveRecord::Base.logger = ActionController::Base.logger = ::Logger.new("/dev/null")
      end
    end
    

    This will reroute all of the Rails logging to the null device, rather than letting it go to a file anywhere. The logging will still happen, but it'll just be immediately trashed.