Rails logging just doesn't work

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 to save the exception, but there were no exceptions.

What could be the problem?

+6
ruby-on-rails logging
source share
3 answers

Have you verified that your production.log file has the correct permissions? Try running sudo chmod 0666 in the production.log file, which may be a problem.

+5
source share

may be:

  • problem with resolution. run "sudo chmod 0666" in the file. rails shows this when the server is running, though
  • rails uses a BufferedLogger. try "logger.flush". You can also customize it.

what does "logger.class" say? which registrar do you use? Is a log file created? What is its permission and permission to the log folder? Are you using a server on webrick (locally?) or a passenger, etc.

eg. if you say "Rails.logger = Logger.new (STDOUT)" then the logs will be sent to the stdout file, not to the file. check that also

+2
source share

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 appropriate environment in the /log application folder.

0
source share

All Articles