Avoid accumulating excess log files

This small patch avoids accumulating unnecessary log files due invalid
command line invocations by moving the log file creation to a later point in
time.