I'm working on a Rails 4 project, and I can't seem to make anything show up in my development log when I call Rails.logger.debug "test"
I've tried searching online but I feel like I haven't made much progress. How would I go about setting up a logger and telling it to write in my development log file?
Any help would be greatly appreciated.
If you want to use
Rails.logger
in a Plain Old Ruby Object orServiceObject
, then you will need to include it manually:Result:
rails has an easy logging mechanism
from inside controller/model
etc.
From Outside these Rails's sections, in Plain Old Ruby objects such as service objects, library objects, you can easily access the same default logger
for rails < 3
for rails > 3
I think you should use it like this in your method. Checkout section 2.3 here
If no logger output appears in your log file, then check to what value log_level has been set in your environments file (config/environments/development.rb, ...) It should either not bee there (default is :debug) or
should be set. Other values are:
More information here: https://guides.rubyonrails.org/debugging_rails_applications.html section 2.2 Log levels