puts vs logger in rails rake tasks

后端 未结 8 1542
情书的邮戳
情书的邮戳 2021-01-30 06:24

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

8条回答
  •  旧巷少年郎
    2021-01-30 06:34

    Rake tasks are run by a user, on a command-line. Anything they need to know right away ("processed 5 rows") should be output on the terminal with puts.

    Anything that needs to be kept for posterity ("sent warning email to jsmith@example.com") should be sent to the Rails.logger.

提交回复
热议问题