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.
Rails makes use of the ActiveSupport::Logger class to write log information. Other loggers, such as Log4r , may also be substituted. You can specify an alternative logger in config/application.rb or any other environment file, for example: config. logger = Logger.
If you want to change all the default logging for that specific model, you can simply use User. logger = Logger. new(STDOUT) or wherever you want to log to. In the same way, ActiveRecord::Base.
In a Rails app, logs are stored under the /log folder. In development mode, the development. log file is used & you see log output on the terminal you're running rails server on.
I think you should use it like this in your method. Checkout section 2.3 here
def your_method logger.debug "This is from debug" logger.info "This is from info" end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With