Create two sets of parameters for the script, so that you can choose in the way that you run it whether it writes output to a file, or to the console.
For example, if the sourcelocation and targetlocation (LogFile/OldLogFile) parameters are given, it should write the output to a file, otherwise it writes to the console.