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?
To write in the current log use the logger. (debug|info|warn|error|fatal|unknown) method from within a controller, model, or mailer: logger. debug "Person attributes hash: #{@person.
logger. debug , or in short logger. debug writes the parameter text to a log file. This log file is by default environment specific. If you are currently running rails in development environment then the log file in use is log/development.
Rails is configured to create separate log files for each of the three default environments: development, test and production. By default it puts these log files in the log/ directory of your project.
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.
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.
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
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')
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