Added logging to log file if debugging is enabled