Improved Log writing.  Now it writes to and closes log file inside a background thread.  This allows for tailing the log and avoids cross thread corruption of log file