Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logger.debug not writing to log file in Rails

Tags:

I am trying to debug a model in Rails so I'm using this code: logger.debug('asasd')

However, I'm tailing the log file development.log but I'm not seeing it add to this file.

  1. I am certain this module is being run
  2. I have confirmed that runtime errors are logging to this file, and I see them when I tail.

How do I get this to work?

like image 777
Justin Avatar asked Apr 05 '11 23:04

Justin


People also ask

Where does Rails logger write to?

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.

How do I create a log file in Rails?

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.

What is the difference between logger INFO and logger debug?

INFO is used to log the information your program is working as expected. DEBUG is used to find the reason in case your program is not working as expected or an exception has occurred. it's in the interest of the developer.


1 Answers

Make sure that you have set the log level to debug in environments/appropriate_env_file.rb:

config.log_level = :debug 

and also make sure you are tailing the correct log file based on the environment you are running against.

like image 84
Wes Avatar answered Oct 13 '22 15:10

Wes