fixed logging. log file was getting closed early because i deferred it in setLogging. Moved setup to main