instead of process.stdout, write to logfile