Rails: Log rake task -


i trying log output of rake task new logger. ideally solution work in development , production.

here task:

task :clients, [:field] => [:setup_logger] |t, args|     clients = client.all     problems = []      group = clients.group_by { |client| client[args[:field]] }     unique_ids = group.keys      unique_ids.each |unique_id|         problems << [unique_id, group[unique_id].length] if group[unique_id].length != 1     end      if !problems.blank?         logger = logger.new("db_issues.log")         logger.error "look @ me"         logger.close     end      p problems end 

when run this, though problems not blank, no new log file created. how supposed accomplish this?

the problem logger.close, after boot server message this:

log writing failed. closed stream

try removing logger.close code , restarting server.


Comments