作为单独的应用程序从日志文件读取数据正在写入它 [英] Reading data from a log file as a separate application is writing to it

查看:187
本文介绍了作为单独的应用程序从日志文件读取数据正在写入它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想监控应用程序正在写入的日志文件。我想要处理文件逐行as,或不久之后,它被写入。我没有找到一种方法来检测文件已经扩展后到达eof。

I would like to monitor a log file that is being written to by an application. I want to process the file line by line as, or shortly after, it is written. I have not found a way of detecting that a file has been extended after reaching eof.

代码需要在Mac和PC上工作,可以是任何语言,虽然我最熟悉C ++和Perl。

The code needs to work on Mac and PC, and can be in any language, though I am most familiar with C++ and Perl.

有没有人建议最好的方法?

Does anybody have a suggestion for the best way to do it?

推荐答案

在Perl中, File:Tail 模块完全符合您的需要。

In Perl, the File::Tail module does exactly what you need.

这篇关于作为单独的应用程序从日志文件读取数据正在写入它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆