Search code examples
javaapache-tailer

How to avoid old log messages in TailerListener


I am using the Apache Commons Tailer API to monitor the log files.

Whenever I restart the application, old log messages are also displayed. Instead only new log messages should get displayed.

How do I avoid this behavior of getting the old log messages?


Solution

  • Did you use the 4-argument Tailer constructor and pass true for the last argument (end)? This should make sure that only new lines are returned.

    The last argument is documented like this:

    Set to true to tail from the end of the file, false to tail from the beginning of the file.