Turn off asset logging in your Rails application

If you’re like me, tailing your development log might provide you with some useful information. The thing I like the most is viewing the details of the queries that happen in the background while you are using your application.

But one thing that makes it harder to keep a proper view on the data that really matters, is the logging of all the assets that get served.

Each request you make will produce an entry for each asset that gets called by the browser:

Started GET "/assets/twitter/bootstrap.css?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200
Started GET "/assets/twitter/bootstrap/_responsive.css?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2013-09-19 12:36:21 +0200

Having those served assets logged will not only create extra noise you need to filter out, it will also make your development log grow more quickly.

Quiet_assets

quiet_assets is a useful gem that turns off the Rails asset pipeline log. This way you won’t find any more entries of served assets in your development log.

Just add the gem to your Gemfile and run bundle:

gem 'quiet_assets', :group => :development
$ bundle

If you need to tail your production log, I recommend piping your output through grep

tail -100f log/development.log | grep -Ev assets

This will suppress the asset output, but will show some blank lines instead. To remove blank lines, use the following command:

tail -100f log/development.log | grep -Ev '(assets|^$)'

So there you go. No more annoying assets you need to scan trough.