http://logging.apache.org/log4j/1.2/
Why logging?Inserting log statements into your code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.
插入日志语句到你的代码中是调试代码的一种基本方法。当不能或不适合使用调试器时,这可能是唯一的一种方法。 On the other hand, some people argue that log statements pollute source code and decrease legibility. (We believe that the contrary is true). 另一方面,一些人争论日志语句污染了源代码和降低了易读性。(我们相信反面是真的)In the Java language where a preprocessor is not available, log statements increase the size of the code and reduce its speed, even when logging is turned off. 在java里预处理器是不可用的,日志语句增加了代码的大小降低了速度,即使日志被关闭。Given that a reasonably sized application may contain thousands of log statements, speed is of particular importance.如果大小适当的应用程序可能包含有大量的日志语句,这时速度尤为重要。
Performance
性能On an AMD Duron clocked at 800Mhz running JDK 1.3.1, it costs about 5 nanoseconds to determine if a logging statement should be logged or not. 在运行JDK 1.3.1,主频800Mhz的AMD 毒龙环境下,花费5纳秒来检测一个日志语句应该记录还是不记录。Actual logging is also quite fast, ranging from 21 microseconds using the SimpleLayout, 37 microseconds using the TTCCLayout. 实际记录是非常快的,范围从使用简单布局的21毫秒,使用TTCCLayout的37毫秒。The performance of the PatternLayout is almost as good as the dedicated layouts, except that it is much more flexible.PatternLayout的性能几乎和专用的布局一样好,只是它更加灵活。Roadmap
路线图The package is being constantly improved thanks to input from users and code contributed by authors in the community.包的持续改进要感谢社区中来自用户的输入和作者的代码贡献。Please note, the team is currently working on log4j 2 which will replace log4j 1 in near future. 请注意,团队现在工作在不久的未来将替换log4j 1 的log4j 2下。