Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24380

Re: Tailing a series of log files

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Tailing a series of log files
Date 2013-06-12 08:56 -0400
Organization A noiseless patient Spider
Message-ID <kp9qt8$l3s$1@dont-email.me> (permalink)
References <3f65c1bd-6589-4b87-b6a9-646250731faa@googlegroups.com>

Show all headers | View raw


On 6/12/2013 8:04 AM, SamXiao wrote:
> Hi all,	
>
> I am working on a solution to keep track of a series of log files and read the tail lines. At the very beginning, there is only one log file named “TEST-YYYYMMDD-00.log” (where YYYYMMDD is the current date). When the size of this log reaches to 10 MB, another log file “TEST-YYYYMMDD-01.log” will be generated and so forth. After midnight (12:00), a new log file with the next date starting with 00 again will be generated.
>
> I know Apache Commons IO containing tail.java. However, seems it is for tailing a single log file only. How could I keep tailing a series of log files?
>
> Any help would be highly appreciated. Thanks.

     It appears you need to monitor the log files' directory for
the creation of new files.  When a new file appears you know
that the log you've been tailing will cease to grow, so you can
stop tailing it and switch your attention to the new one.  Maybe
you should continue tailing the old for a few seconds before
making the switch (just in case a final buffer needs to get
flushed or something), but I think that should do it.

     I don't know whether anybody's already packaged such a thing
in a form you can just pick up and use, but it seems straightforward
enough.  Take a look at

http://docs.oracle.com/javase/tutorial/essential/io/notification.html

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Tailing a series of log files SamXiao <foolsmart2005@gmail.com> - 2013-06-12 05:04 -0700
  Re: Tailing a series of log files Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-12 08:56 -0400
  Re: Tailing a series of log files Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-14 20:00 -0300
    Re: Tailing a series of log files Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-14 21:06 -0400
      Re: Tailing a series of log files Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-06-14 21:11 -0700
        Re: Tailing a series of log files Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-06-15 09:20 -0400
          Re: Tailing a series of log files JLP <JLP@jlp.com> - 2013-06-15 18:59 +0200
            Re: Tailing a series of log files JLP <JLP@jlp.com> - 2013-06-15 19:15 +0200
      Re: Tailing a series of log files Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-06-16 16:43 -0300

csiph-web