I'm trying to reactively tail a log file using RxJava-File:
File file = new File(".\\server.log");
Observable<String> newLines =
FileObservable.tailer()
.file(file)
.startPosition(file.length())
.sampleTimeMs(1000)
.chunkSize(8192)
.utf8()
.tailText();
newLines.subscribe(System.out::println);
and it works as expected. But as soon as I try to chain some more operators, I get problems. For instance, changing to
newLines.filter(LogfileWatcher::error).subscribe(System.out::println);
(where error()
is a simple function String -> Boolean
) I get output only after the first append to the file, but not the subsequent ones.
Similar problems appear when using window()
or several other operators.
What am I doing wrong?