开发者

how to avoid old log messages when restarting the TailerListener

开发者 https://www.devze.com 2023-02-22 06:37 出处:网络
I am using TailerListener API for monitoring log files. It\'s working fine if process started. If we restart the TailerListener,ii is monitoringlogs which are older than this process start up tim开发

I am using TailerListener API for monitoring log files. It's working fine if process started. If we restart the TailerListener,ii is monitoring logs which are older than this process start up tim开发者_如何学Ce. Is there any way to avoid this.

Thanks in advance.


File in java has a lastModified() method. Before creating the Tailer, check it.


Is your file being rotated? See if below is what you are asking, because I have run into this before. When the file is rotated the default behavior seems to be to spit out all the log message from the whole log file, instead of only new log messages. So my question would be, how do I override fileRotated() in TailerListener or change the behavior to avoid rolling the whole log file again (old and new messages)?

0

精彩评论

暂无评论...
验证码 换一张
取 消