我正在使用 Apache Commons Tailer API 来监控日志文件。
每当我重新启动应用程序时,也会显示旧的日志消息。相反,应该只显示新的日志消息。
如何避免这种获取旧日志消息的行为?
最佳答案
你用过4-argument Tailer
constructor吗?并为最后一个参数 (end
) 传递 true
?这应该确保只返回新行。
最后一个参数是这样记录的:
Set to
true
to tail from the end of the file,false
to tail from the beginning of the file.
关于java - 如何避免 TailerListener 中的旧日志消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5896375/