You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "santhoshp2006@gmail.com" <sa...@gmail.com> on 2011/06/14 11:01:32 UTC

in java apache.commons.io,how to avoid to read the old log messages.

i am using the java Tail-listener API to do the tailf function(in
Linux).ie,whenever log messages are updated in log file, this API will print
the messages.

My code is given below.

    public static void main(String[] args) {
        // TODO code application logic here
        File pcounter_log = new File("\vat\temp\test.log");

        try {
            TailerListener listener = new PCTailListener();
            Tailer tailer = new Tailer(pcounter_log, listener, 5000, true);

            Thread thread = new Thread(tailer);
            thread.start();
        } catch (Exception e) {
            System.out.println(e);
        }
    }

public class PCTailListener extends TailerListenerAdapter {
    public void handle(String line) {
        System.out.println(line);
    }
}

Initially its working fine.After some time,its reading the old log messages
(log messages which are generated at the time of log filr
creation.ie,starting of the log file). also its reading new log messages
too. how to avoid to read the already monitored log messages.How to do this


--
View this message in context: http://apache-commons.680414.n4.nabble.com/in-java-apache-commons-io-how-to-avoid-to-read-the-old-log-messages-tp3596022p3596022.html
Sent from the Commons - Issues mailing list archive at Nabble.com.

Re: in java apache.commons.io,how to avoid to read the old log messages.

Posted by sebb <se...@gmail.com>.
Please don't send usage questions to the issues list.

Please subscribe to the user mailing list and post there.
Please also prefix the subject line with the Commons Component, i.e. [IO]
See: http://commons.apache.org/mail-lists.html


On 14 June 2011 10:01, santhoshp2006@gmail.com <sa...@gmail.com> wrote:
> i am using the java Tail-listener API to do the tailf function(in
> Linux).ie,whenever log messages are updated in log file, this API will print
> the messages.
>
> My code is given below.
>
>    public static void main(String[] args) {
>        // TODO code application logic here
>        File pcounter_log = new File("\vat\temp\test.log");
>
>        try {
>            TailerListener listener = new PCTailListener();
>            Tailer tailer = new Tailer(pcounter_log, listener, 5000, true);
>
>            Thread thread = new Thread(tailer);
>            thread.start();
>        } catch (Exception e) {
>            System.out.println(e);
>        }
>    }
>
> public class PCTailListener extends TailerListenerAdapter {
>    public void handle(String line) {
>        System.out.println(line);
>    }
> }
>
> Initially its working fine.After some time,its reading the old log messages
> (log messages which are generated at the time of log filr
> creation.ie,starting of the log file). also its reading new log messages
> too. how to avoid to read the already monitored log messages.How to do this
>
>
> --
> View this message in context: http://apache-commons.680414.n4.nabble.com/in-java-apache-commons-io-how-to-avoid-to-read-the-old-log-messages-tp3596022p3596022.html
> Sent from the Commons - Issues mailing list archive at Nabble.com.
>