Lonny has asked for the wisdom of the Perl Monks concerning the following question:

I have a process that writes to a log file with a max size of 1 mb. My goal is to count events in this log file over a 24 hour period. Each event (snmp) is comprised of several lines in the log file. Each event begins with "enterprise:". Counting the events is simple enough.

My quandry lies in maintaining the filehandle on the log file for reading across the rotation. I.e. at MaxFileSize the log is renamed and a new log file is created by the same name. I thought there was a module that would handle this, however I am quickly coming to the realization that there is not.



Any advice?
Thanks for anything you can offer.

Replies are listed 'Best First'.
Re: Filehandle on rotating log
by idsfa (Vicar) on Oct 23, 2003 at 21:59 UTC

    You can't get there from here.

    Rotating the log means that the old file is renamed and then a new file is opened for the new log entries. You will have to change to a model where you open the file, read it and close it each time you want to update your statistics.


    Remember, when you stare long into the abyss, you could have been home eating ice cream.
      Ah well. I suppose if it were easy to accomplish, it wouldn't be worth doing.
      Thanks, though.