Logging

Fixed the path to the log file and handle errors when writing to the log