N.B. Apache Camel stream component seems very promising for real life applications. Though I neved tried it.
alaz / tailf Goto Github PK
View Code? Open in Web Editor NEWtail -f written in Scala
tail -f written in Scala
N.B. Apache Camel stream component seems very promising for real life applications. Though I neved tried it.
Ran into a StackOverflowError while letting this tail a file for a while (over 10 min). Log file was idle the entire time.
Exception in thread "Thread-10" java.lang.StackOverflowError
at sun.nio.ch.FileChannelImpl.position(FileChannelImpl.java:253)
at com.osinka.tailf.FollowingInputStream.rotated_$qmark(Tail.scala:104)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:109)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
followed by a ton of FollowingInputStream.handle lines. There are a total of 1020 of the following lines in the stacktrace:
at com.osinka.tailf.FollowingInputStream.handle(Tail.scala:112)
Full stacktrace here: http://pastebin.com/YEyrWnFv
Using Java 1.6u45 and Scala 2.10.4
I called Tail like this
def read(r: BufferedReader): Unit = {
if (!Thread.currentThread().isInterrupted) {
val l = r.readLine
if (l != null) {
log.info(s"read line: $l")
}
read(r)
} else {
r.close()
log.info("read() Shutdown!")
}
}
val file: File = new File(logFile)
val r = new BufferedReader(new InputStreamReader(Tail.follow(file)))
val readerThread = new Thread(new Runnable {
def run() {
read(r)
}
})
readerThread.setDaemon(true)
readerThread.start()
Hi Alex,
I can't figure out what is this good for. It allows for surviving log rotation and still keep the handle to the log file that is backed up. But at that point it makes no sense to keep reading such file, right ?
Wouldn't it make more sense if it was able to continue with reading the new file that was created after the old was rotated? So that it could feel like it is reading one file but actually it would be xth file that it is reading after surviving rotation.
Thank you, Jakub
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.