I would like to view some variables in controller, it tried the following:
Rails.logger.debug "Year: #{Time.now.year}"
puts "Year: #{Time.now.year}, Month: #{@month}"
where can I see the output for Logger or Puts in production mode? Do I need so set something up to view these somewhere?
The normal log level in production is
info
, sodebug
logs are not shown.Change your logging to
to show it in
production.log
.Alternatively (but not a good idea) you can raise the logging level in
/config/environments/production.rb
:Update Rails 4.2:
Now the default debug level in all environments is
:debug
(as @nabilh mentioned).If you want you production environment less chattery, you can reset your log level in
/config/environments/production.rb
to the former:info
:While I believe @martin-m is right that you probably don't want to clutter your logs by using
config.log_level = :debug
in/config/environments/production.rb
, I believe the default logging level in all environments isdebug
as of Rails 4.2. Sodebug
logs (and all levels up) will be shown in production unless you specify otherwise.So in response to your question, you can now write:
Rails.logger.debug "Year: #{Time.now.year}"
and see the results in/log/production.log
.See here for more detailed documentation. Here is the documentation for Rails 4.1 for comparison.