title: How to clear a log file programatically?
body: <p>I have two log files setup in a logback file. </p>
  
  <pre><code>&lt;appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
                &lt;fileNamePattern&gt;/opt/loghome/${instance}/recon.%d{MM-dd-yyyy}.log.zip
                &lt;/fileNamePattern&gt;
                &lt;maxHistory&gt;30&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
          &lt;append&gt;false&lt;/append&gt;
          &lt;encoder&gt;
                &lt;pattern&gt;%d{MM/dd/yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%X{User} %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
    &lt;/appender&gt;
  
    &lt;appender name="datafile1" class="ch.qos.logback.core.FileAppender"&gt;
          &lt;file&gt;/opt/loghome/datafiles/file1.log&lt;/file&gt;
          &lt;append&gt;false&lt;/append&gt;
          &lt;encoder&gt;
                &lt;pattern&gt;%msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
    &lt;/appender&gt;
  </code></pre>
  
  <p>In java these are set up like so:</p>
  
  <pre><code>private static final Logger logger = LoggerFactory
                .getLogger(Main.class);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>private static final Logger logger = LoggerFactory
                .getLogger("datafile1");
  </code></pre>
  
  <p>The first is the standard application log file. The second stores data which the program retreives from a db.</p>
  
  <p>The program then compares data within the logfile and sends out some results. After this is completed, I would like to clear this log(datafile1) so it is empty and ready for the next run. How can I do this?</p>
  
  <p>N.b the program is a 24hour process that uses a scheduler to run this job. It does not restart each time the job is run.</p>