Reputation: 36101
I'm trying to do easy logging
logger.error "ERROR!!!"
But nothing is displayed in any of the log files in the /log directory. I tried rescuing an exception, but there's no exception.
What might be the problem here?
Upvotes: 8
Views: 5346
Reputation: 2117
Check output of Rails.logger
. If it shows RailsStdoutLogging::StdoutLogger:0x00007fe3b5bc3540
means you are logging on shell. Change it to ActiveSupport::Logger
by creating an initializer.
config/initializer/logger.rb
Rails.logger = ActiveSupport::Logger.new('log/production.log')
Upvotes: 1
Reputation: 25566
I had a similar problem trying to use logger.debug
and RAILS_DEFAULT_LOGGER.debug
.
However, the following works:
Rails.logger.debug 'hello world'
Then check the logs for the corresponding environment in your app's /log
folder.
Upvotes: 0
Reputation: 8080
there might be a:
what does "logger.class" say? what logger are you using? is the log file created? what is its permission and the permission for the log folder? are you running the server on webrick (locally ?) or passenger etc?
eg. if you say "Rails.logger = Logger.new(STDOUT)" then the logs will go to stdout rather than a file. check that as well
Upvotes: 2
Reputation: 51
Did you check that your production.log file has the proper rights? Try running sudo chmod 0666
on your production.log file, that might be the problem.
Upvotes: 5