In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production.
However if I s
I'd say that using Rails.logger.info
is the way to go.
You won't be able to see it in the server console because it won't run via the server. Just open up a new console and tail -f
the log file, it'll do the trick.
Many users are aware of the UNIX® command 'tail', which can be used to display the last few lines of a large file. This can be useful for viewing log files, etc.
Even more useful in some situations, is the '-f' parameter to the 'tail' command. This causes tail to 'follow' the output of the file. Initially, the response will be the same as for 'tail' on its own - the last few lines of the file will be displayed. However, the command does not return to the prompt, and instead, continues to 'follow' the file. When additional lines are added to the file, they will be displayed on the terminal. This is very useful for watching log files, or any other file which may be appended over time. Type 'man tail' for more details on this and other tail options.
(via)