Exactly how slow are C, F, L, l and M of PatternLayout (log4j)?

后端 未结 3 1900
再見小時候
再見小時候 2020-12-31 10:00

It\'s common knowledge that C, F, L, l and M of PatternLayout are slow:

WARNING Gener

3条回答
  •  盖世英雄少女心
    2020-12-31 10:53

    I measured locally on my computer using a FileAppender. I warmed up the test nicely, measured many executions and averaged the (relatively consistent) results. The loop contained execs++;log.info("t");The exact numbers do not matter (because they depend on my computer) but proportions do. I used log4j-1.2.16.jar on Java 1.6.0_10 (Client VM).

    It turns out that whenever any of the C, F, L, l or M appeared in the pattern, logging was at least 5 times slower.

    enter image description here

提交回复
热议问题