Rails, logger in development mode: console vs logfile

Rails 3.0 how important this is.

Thus, usually in design mode, logger messages are written to both console.log and the console if you are in the interactive console.

It's just awesome, wonderful.

But something I can’t understand, if I write a logger message at the time (for example, in config.after_initialize), then this does NOT happen. The log message is in the log / development.log file, but NOT written to the console. Which is annoying, the reason I write something during the download process (echo'ing a specific configuration) for the developer to see it, because it helps in debugging.

Does anyone know what is going on here, and if anything I can do it?

+4
source share
1 answer

All you have to do is add a print statement before calling your log, for example:

config.after_initialize do print Rails.logger.info("Testing") end 

The Rails console will not automatically display anything during initialization, but will display everything that you pass with the print instruction. Rails.logger returns the value that it writes to the log, so it really is that simple.

+4
source

All Articles