Andy Malakov software blog

Monday, July 27, 2009

Faster JUL logging

Here are the steps we followed to improve java.util.logging performance:


  1. Switched from SimpleFormatter to our custom formatter. It boosted performance up to 6 times. Our formatter prints only time-of-day portion of timestamp (using custom formatting function). Our log files also omit class/method/thread context for each log message. It also uses custom MessageFormatter (based on StringBuilder).


  2. Tweaked FileHandler to flush every 8K rather than after each message. This boosts performance up to 2.5 times.


  3. We tried using Java7 logger package. We didn't notice considerable improvements for our usage patterns.



Credit for much of this work goes to my colleague Nikolay Dul.

Wednesday, July 22, 2009

Java logging

Am I the only one who misses


public void log (Level level, String msg, Object ... params)


Instead of existing


public void log (Level level, String msg, Object [] params)


in java.util.logging.Logger ?

P.S. Apparently not: enhancement request was filed back in 2004. I will see what I can do...