开发者

Rails console log - how to customize what is printed in the console

开发者 https://www.devze.com 2023-04-08 18:20 出处:网络
When I run rails s it loads up and everything works.When I browse to a page开发者_如何学Python several lines of information are printed.Mostly this isthe webpage getting the assets for the page.I real

When I run rails s it loads up and everything works. When I browse to a page开发者_如何学Python several lines of information are printed. Mostly this is the webpage getting the assets for the page. I really don't need to see this and have it clutter my screen. Is there a way to customize what gets printed in console?

Thanks


For assets pipeline messages it seems that you can't (yet). See How to disable logging of asset pipeline (sprockets) messages in Rails 3.1? and the rails issue on Github

You can do it in part by using these lines (credits) in your development.rb file

config.after_initialize do |app|
  app.assets.logger = Logger.new('/dev/null')
end


For Rails 3.1, inside config/environments/development.rb, set the following to false:

config.assets.debug = false

Your logs will show you everything you want to see minus the assets.


You can configure the logging detail of the rails dev server by setting config.log_level in environments/development.rb. Setting it to :warn will get rid of most of the logging (you can always send your own messages with whatever log level you want so they still get printed).

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号