Only create log file when installing.

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.