Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails server console output very noisy, can it be turned off?

On some of my rails application pages I am seeing reams and reams of information echoed out to the console, messages that I am not interested in such as http messages:

  Started GET "/assets/jquery_ui/jquery-ui-1.8.16.custom.css?body=1" for 10.0.2.2 at       2012-03-02 15:19:59 +0000
  Served asset /jquery_ui/jquery-ui-1.8.16.custom.css - 304 Not Modified (0ms)

There is also lots of SQL statements that I don't normally care about.

Sure, I can see how sometimes this level of information would be helpful sometimes. But I would like to run my server normally without this noise.

The reason for this is because if I am debugging an issue, I like to explicitly log messages to the console, run the request and observe the output. However finding my own logs in amongst this noise is time consuming!

Currently to work around this I am marking my messages with a magic string and greping the output to the console...

Can anybody suggest a nicer way to reduce the console output to just my own messages?

I am on rails 3.1.

Thanks for any suggestions.

like image 861
Chris Avatar asked Mar 02 '12 16:03

Chris


People also ask

How do you escape the console in Rails?

To exit the console, type: quit .

What is logger in Rails?

Rails makes use of the ActiveSupport::Logger class to write log information. Other loggers, such as Log4r , may also be substituted. You can specify an alternative logger in config/application.rb or any other environment file, for example: config. logger = Logger.

What does Rails console do?

The console command lets you interact with your Rails application from the command line. On the underside, bin/rails console uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.

What happens when we run Rails server?

One of the things rails server does is that it loads all the dependencies/gems required by your Rails app, or at least sets them up to be auto-loaded later when they are needed. This is sometimes called "booting" or loading the "Rails environment".


2 Answers

You can raise the logging level in config/environments/development.rb from info to warn

http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels

like image 101
danpickett Avatar answered Oct 05 '22 04:10

danpickett


Add Quiet Assets to the development group of your Gemfile.

like image 29
Strand McCutchen Avatar answered Oct 05 '22 05:10

Strand McCutchen