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.