我的代碼如下。在java中TailListener,如何避免重複的日誌消息
public static void main(String[] args) {
// TODO code application logic here
File pcounter_log = new File("c:\development\temp\test.log");
try {
TailerListener listener = new PCTailListener();
Tailer tailer = new Tailer(pcounter_log, listener, 5000,true);
Thread thread = new Thread(tailer);
thread.start();
} catch (Exception e) {
System.out.println(e);
}
}
public class PCTailListener extends TailerListenerAdapter {
public void handle(String line) {
System.out.println(line);
}
}
.IE,我監測file.whenever登錄日誌文件更新消息的日誌(C:\研發\ TEMP \ test.log中),將打印日誌消息。
問題是,無論何時在日誌文件中更新日誌消息,它都會顯示相同的日誌消息兩次,有時候會顯示三次或四次,以避免重複的日誌消息。