PatternLayout(log4j)的C,F,L,l和M有多慢? [英] Exactly how slow are C, F, L, l and M of PatternLayout (log4j)?
问题描述
常见的知识是 C
, F
, L
, l
和 M
PatternLayout 很慢:
It's common knowledge that C
, F
, L
, l
and M
of PatternLayout are slow:
警告生成来电者位置信息是非常缓慢,应该避免,除非执行速度不是问题。
WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue.
另外,这本书提到一些应用程序只能从更改日志记录格式获得10%的速度。
Also, this book mentions that some applications can gain 10% speed only from changing the logging format.
但问题是,这些转换字符?
But the question is, exactly how slow are these conversion characters?
推荐答案
我使用FileAppender在本地计算机上测量。我很好地预热了测试,测量了许多执行和平均(相对一致的)结果。循环包含 execs ++; log.info(t);
确切的数字并不重要(因为它依赖于我的电脑),而是比例。我在Java 1.6.0_10(Client VM)上使用了log4j-1.2.16.jar。
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).
事实证明,每当 C, F,L,l或M
出现在模式中,日志记录速度至少要慢5倍。
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.
这篇关于PatternLayout(log4j)的C,F,L,l和M有多慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!