Log4J - 解析类/方法/行引用的速度
log4J 是否仍然通过生成异常和检查堆栈跟踪来收集类、方法和行号?
或者自从 Sun 包含了他们自己的日志框架以来 Java 已经得到了优化。
如果不是,为什么此后没有进行任何优化。 快速有效地获取类、方法和行号的主要挑战是什么?
虽然我讨厌注释并试图避免它们,但是log4J没有使用它,例如:
@log4j-class MyClass
@log4j-method currentMethodOne
至少这可以避免一些公司重复编写/复制方法名称作为方法名称的坏习惯他们的日志消息的第一部分(这非常烦人)。
谢谢,
杰奇!
Does log4J still gather the class, method and line numbers by generating exceptions and inspecting the stack trace?
Or has Java been optimized since Sun included their own logging framework.
If not, why has there not been any optimizations made since. What is the main challenges in obtaining class, method and line numbers quickly and efficiently?
Although I hate annotations and try to avoid them, has log4J not made use of this, such as:
@log4j-class MyClass
@log4j-method currentMethodOne
At least this would avoid some companies bad habit of repeatedly writing/copying the method name as the first part of their logging message (which is seriously annoying).
Thanks,
Jeach!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据此页面,Log4j的最后一次更新是在2007年8月我从未听说过注释支持,也不明白它的用途。
至于方法名称是日志消息,您可以随时编辑
log4j.properties
或log4j.xml
配置文件,并更改 所需附加程序的布局模式。 该模式将适用于您自己的类和任何使用 log4j 的第三方库 - 这是使用记录器的目的之一。只需在布局模式中省略
M
,Log4j 就不会收集调用者信息。According to this page, last update of Log4j was in August, 2007. I never heard of annotation support, nor do I understand what purpose would it have.
As for the method name is the logging message, you can always edit
log4j.properties
orlog4j.xml
configuration file, and change the layout pattern of the desired appender. The pattern will apply to your own classes and any 3rd party libraries using log4j - that is one of the purposes of using a logger.Just omit the
M
in the layout pattern and Log4j won't be gathering caller information.