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

后端 未结 3 1899
再見小時候
再見小時候 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:32

    The primary reason that these are marked as slow, is because the information they represent is retrieved by throwing an exception and analyze the stack trace of the exception.

    When PatternLayout was designed, stack trace generation was a very expensive process, so this was fair warning. Advances in JVM technology has improved on this so the process is not as expensive anymore. Even though there is faster methods to derive the needed information today, these are - to my knowledge - not being used due to attention to backwards compatibility with earlier versions of Java.

    In other words, this is not as bad as it used to be.

提交回复
热议问题