move file logging to prepare_file