connection: Move definition of log file name inside the bracketing if