Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have rails log errors when seeding

I have a rails app with a lot of information in the seed process. Is there a way to set it so that it logs to one of the log files?

like image 646
timpone Avatar asked Feb 10 '12 04:02

timpone


3 Answers

If your just running your seeds with the rake db:seed task you could do:

$ rake db:seed --trace
like image 61
JDutil Avatar answered Sep 23 '22 05:09

JDutil


Rails.logger.debug("Message") will go to the log/development.log file.

You can do this in console tail -f log/development.log to see it in action.

like image 41
Mark Swardstrom Avatar answered Sep 20 '22 05:09

Mark Swardstrom


Try

say_with_time("Doing this and that") do
  # seed stuff
end

to make your seeds more verbose, and redirect to a file via '> log'. I suppose you could hijack the logger at init time and use a file-logger instead, if you don't like the '> log' solution.

like image 1
dynex Avatar answered Sep 22 '22 05:09

dynex