Reputation: 2973
Coming from a javascript background, I find the command line while running rails to be cluttered. Every time something happens, my command line is filled with a bunch of crap. E.g:
[2013-06-19 20:25:53] WARN Could not determine content-length of response body.
Set content-length of the response or set Response#chunked = true
How do I turn this off so that I only see my own logs(and errors, of course)?
Any help is appreciated!
Upvotes: 12
Views: 15391
Reputation: 25294
./.env
usually file .env is used to store all important / secret properties of your application environment. Create .env if not exist and add code:
RAILS_LOG_TO_STDOUT=true
./config/environments/*.rb
edit your environment file (e.g. ./config/environments/development.rb) to create a disconnectable logging system.
Rails.application.configure do
# ...
if ENV['RAILS_LOG_TO_STDOUT'] == 'true'
logger = ActiveSupport::Logger.new(STDOUT)
# To support a formatter, you must manually assign a formatter from the config.log_formatter value to the logger.
logger.formatter = config.log_formatter
# config.logger is the logger that will be used for Rails.logger and any
# related Rails logging such as ActiveRecord::Base.logger.
# It defaults to an instance of ActiveSupport::TaggedLogging that wraps an
# instance of ActiveSupport::Logger which outputs a log to the log/ directory.
config.logger = ActiveSupport::TaggedLogging.new(logger)
# config.log_level defines the verbosity of the Rails logger.
# This option defaults to :debug for all environments.
# The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown
#config.log_level = :debug
# config.log_tags accepts a list of: methods that the request object responds to,
# a Proc that accepts the request object, or something that responds to to_s.
# This makes it easy to tag log lines with debug information like subdomain and request id -
# both very helpful in debugging multi-user production applications.
config.log_tags = [:request_id]
end
end
set RAILS_LOG_TO_STDOUT=true
in .env to turn on console logger
delete or comment out line RAILS_LOG_TO_STDOUT=true
, or set RAILS_LOG_TO_STDOUT=false
in .env to turn off console logger
How to start Rails server with environment variables set?
Configuring Rails Applications
Upvotes: 0
Reputation: 48709
Change the log level in config/environments/development.rb
, and/or testing.rb
:
config.log_level = :error
The log levels available are: :debug
, :info
, :warn
, :error
, :fatal
, and :unknown
, which correspond to the integers 0
-5
.
Upvotes: 7
Reputation: 172
Try changing the log level, which is info by default.
From the Guides: http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels
Upvotes: 10
Reputation: 467
You can turn off the SQL queries. I know they take a lot of room.
Disable Rails SQL logging in console
Upvotes: 1