Reputation: 661
I have been using this "puts" for checking some values in production, then i can see that in logs, so which one is the best way to get that in production logs, is it "Rails.logger.debug" or "puts"
Upvotes: 0
Views: 1239
Reputation: 13014
Use Rails.logger. Logger comes with different levels (from 0 to 5) like:
Logging will help you to tag the message nicely and in the file, it then appears in proper log format (with timestamps and request_ids if enabled).
This is useful when you want to log under development or staging without flooding your production log with unnecessary information.
puts
will not give all the above flexibility. If you are using either from development debugging point of view, it doesn't matter much, but I would still prefer Rails.logger for request_id tagging purposes :)
Upvotes: 4