title: SLF Releasing File Lock
body: <p>I have a program which uses SLF for logging. This program runs 24/7 and I would like to upload the log files to a remote server every night for later review. </p>
  
  <p>My question is, how do I release the file lock for the log without closing the program? </p>
  
  <p>I was hoping to suspend logging, upload the logs, either delete the log file or erase the contents, and then resume logging.</p>
  
  <pre><code>ILogger logger = LoggerService.GetLogger(typeof(TaskScheduler).FullName);
  
  // Other initialization here
  
  foreach (var task in managedTasks.OrderBy(t =&gt; t.Priority))
  {
      if (task.NextRunTime &lt;= DateTime.Now)
      {
          dataManager.CurrentStatus = AppStatus.Running;
          if (task.Name == "Log Sender")
          {
               logger = null;
          }
  
          // Run the task
  
          if (task.Name == "Log Sender")
          {
              logger = LoggerService.GetLogger(typeof(TaskScheduler).FullName);
          }
  
          dataManager.CurrentStatus = AppStatus.Idle;
      }
  }
  </code></pre>
  
  <p>Currently, when I do this, I'm still getting an IOException because the file is still locked by the Task Scheduler. </p>
  
  <p>EDIT: I'm using SLF over log4net if that helps.</p>