title: Apache Commons IO Tailer delivers old log messages
body: <p>My code is given below.</p>
  
  <pre><code>public static void main(String[] args) {
      // TODO code application logic here
      File pcounter_log = new File("c:\development\temp\test.log");
  
  try {
  
      Tailer tailer = new Tailer(pcounter_log, new FileListener("c:\development\temp\test.log",getLogPattern()), 5000,true);
  
      Thread thread = new Thread(tailer);
      thread.start();
  } catch (Exception e) {
      System.out.println(e);
  }
  }
  
  public class FileListener extends TailerListenerAdapter {
  
  
   public void handle(String line) {
          for (String logPattern : pattern) {
              if (line.contains(logPattern)) {
                  logger.info(line);
  
              }
          }
      }
  }
  </code></pre>
  
  <p>Here <code>getLogPattern()</code> returns an <code>ArrayList</code> containing values like [info,error,abc.catch,warning]. When running this code, I get old log message followed by new log message. I.e. the output is like this:</p>
  
  <pre><code>20 May 2011 07:06:02,305  INFO FileListener:? - 20 May 2011 07:06:01,230 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:06:55,052  INFO FileListener:? - 20 May 2011 07:06:55,016 DEBUG  - readScriptErrorStream()
  20 May 2011 07:06:56,056  INFO FileListener:? - 20 May 2011 07:06:55,040 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:07:01,241  INFO FileListener:? - 20 May 2011 07:07:01,219 DEBUG  - readScriptErrorStream()
  20 May 2011 07:07:02,245  INFO FileListener:? -  20 May 2011 07:07:01,230 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:07:55,020  INFO FileListener:? -  20 May 2011 07:07:55,016 DEBUG  - readScriptErrorStream()
  20 May 2011 07:07:56,024  INFO FileListener:? - 20  2011 07:07:55,030 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:08:01,269  INFO FileListener:? -  20 May 2011 07:08:01,227 DEBUG - readScriptErrorStream()
  20 May 2011 07:08:02,273  INFO FileListener:? -  20 May 2011 07:08:01,230 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:08:21,234  INFO FileListener:? -  20 May 2011 06:40:02,461 DEBUG  - readScriptErrorStream()
  20 May 2011 07:08:22,237  INFO FileListener:? -  20 May 2011 06:40:02,468 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:08:23,242  INFO FileListener:? -  20 May 2011 06:41:01,224 DEBUG - readScriptErrorStream()
  20 May 2011 07:08:24,250  INFO FileListener:? -  20 May 2011 06:41:01,232 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:08:25,261  INFO FileListener:? -  20 May 2011 06:42:01,218 DEBUG  - readScriptErrorStream()
  20 May 2011 07:08:26,265  INFO FileListener:? -  20 May 2011 06:42:01,230 DEBUG   - exiting readScriptErrorStream()
  20 May 2011 07:08:27,272  INFO FileListener:? -  20 May 2011 06:43:01,223 DEBUG  - readScriptErrorStream()
  20 May 2011 07:08:28,275  INFO FileListener:? -  20 May 2011 06:43:01,231 DEBUG   - exiting readScriptErrorStream()
  </code></pre>
  
  <p>How to avoid to get old log messages from log file like this?</p>