Log4J - 解析类/方法/行引用的速度

发布于 2024-07-16 02:51:45 字数 344 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲性难收 2024-07-23 02:51:45

根据页面,Log4j的最后一次更新是在2007年8月我从未听说过注释支持,也不明白它的用途。

至于方法名称是日志消息,您可以随时编辑 log4j.propertieslog4j.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 or log4j.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文