[logback-user] log4j performance comparison

hostalp at post.cz hostalp at post.cz
Mon Mar 21 11:55:32 CET 2011

Yeah, with few more (and hopefuly last) things to add:

Not flushing after every line doesn't seem to make a difference for FileOutputStream in isolated tests (I was getting identical times as with flushing) - unless buffering of course - but it does make difference with logback which uses this FileOutputStream.
However logback wraps OutputStreamWriter around it and then it really makes that difference - and also results become very close (almost identical) to FileWriter then.

Java 1.5 only:
OutputStreamWriter/FileOutputStream immediateFlush: 8435
OutputStreamWriter/FileOutputStream no-flush: 1160
BufferedWriter/OutputStreamWriter/FileOutputStream no-flush: 922

FileWriter immediateFlush: 8271
FileWriter no-flush: 1150
BufferedWriter/FileWriter no-flush: 918

In real logging scenarios it looks to me that immediateFlush=false decreases times to 1/2-1/3 and buffering can give further 10-15% improvement with properly sized buffer.

So I definitely vote for bringing at least the immediateFlush=false option back.
Bringing back buffering would also be great as one can get a bit more performance out of it - and every little bit does matter for us here. :)

More information about the Logback-user mailing list