Inheritance: System.Diagnostics.TraceListener
        internal static void MoveToFile(string filename)
        {
            if (logFile == null)
            {
                throw new Exception("Attempt to rename non-existing log file to {0}".F(filename));
            }

            TraceInfo.WriteLine("Renaming logging to file {0}", filename);

            WaitToQueueEmpty(logFile);

            Trace.Listeners.Remove(logFile);
            logFile.Dispose();

            var retryCount = 2;

            while (retryCount > 0)
            {
                try {
                    File.Move(logFile.FileName, filename);
                    retryCount = 0;
                } catch (IOException) {
                    retryCount--;
                    Thread.Sleep(1000);
                }
            }

            logFile = new LogListener(filename);
            Trace.Listeners.Add(logFile);
        }
        private static void WaitToQueueEmpty(LogListener oldLogFile)
        {
            var count = 10;

            while (count-- > 0 && oldLogFile.items.Count > 0)
            {
                Thread.Sleep(10);
            }
        }
        public static void ToFile(string filename)
        {
            var oldLogFile = logFile;

            logFile = new LogListener(filename);
            Trace.Listeners.Add(logFile);

            if (oldLogFile != null)
            {
                TraceInfo.WriteLine("Moving logging to file {0}", filename);

                WaitToQueueEmpty(oldLogFile);

                Trace.Listeners.Remove(oldLogFile);
                oldLogFile.Dispose();
            }
        }
        internal static void ToFile(string filename)
        {
            var oldLogFile = logFile;
            logFile = new LogListener(filename);
            Trace.Listeners.Add(logFile);

            if (oldLogFile != null)
            {
                TraceInfo.WriteLine("Moving logging to file {0}", filename);

                WaitToQueueEmpty(oldLogFile);

                Trace.Listeners.Remove(oldLogFile);
                oldLogFile.Dispose();
            }
        }
        internal static void MoveToFile(string filename)
        {
            if (logFile == null)
                throw new Exception("Attempt to rename non-existing log file to {0}".F(filename));

            TraceInfo.WriteLine("Renaming logging to file {0}", filename);

            WaitToQueueEmpty(logFile);

            Trace.Listeners.Remove(logFile);
            logFile.Dispose();

            var retryCount = 2;
            while( retryCount > 0 ) {
                try {
                    File.Move(logFile.FileName, filename);
                    retryCount = 0;
                } catch(IOException) {
                    retryCount--;
                    Thread.Sleep(1000);
                }
            }

            logFile = new LogListener(filename);
            Trace.Listeners.Add(logFile);
        }
 private static void WaitToQueueEmpty(LogListener oldLogFile)
 {
     var count = 10;
     while (count-- > 0 && oldLogFile.items.Count > 0)
         Thread.Sleep(10);
 }