比较log4j和Logger [英] Compare log4j and Logger

查看:279
本文介绍了比较log4j和Logger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JDK的记录器与Apache log4j 进行比较?

How does The JDK's Logger compare to Apache log4j?

其中对于面向Java 6的新项目,哪个更好?他们如何在灵活性和可配置性方面进行比较?

Which one is better for new projects that target Java 6? How do they compare in terms of flexibility and configurability?

推荐答案

在我看来,JDK Logger唯一能做到的就是它是JDK的一部分,因此它不会添加外部依赖项。如果选择只在这两者之间,我会选择Log4j。对于appender,知道它的人数(在我的轶事观察中)以及更好的API(也是主观的),它仍然有更好的支持。

To my mind the only thing the JDK Logger has going for it is that it is part of the JDK, so it doesn't add an external dependency. If the choice is only between those two, I'd go with Log4j. It still has better support in terms of appenders, the number of people who know it (in my anecdotal observations), and a better API (that is subjective as well).

今天开始一个项目,最有吸引力的事情就是使用slf4j并做出决定 - 只需更改类路径,你就可以在slf4j下面插入一个不同的框架。

Starting a project today, the most tempting thing to do is go with slf4j and deffer the decision - you can always plug in a different framework underneath slf4j by just changing the classpath.

据说还有其他选项(如Log5j)可以利用最新的Java语言功能。我建议你仔细看看 Logback (来自Log4j的一个主要程序员,就像slf4j一样)。

That being said there are other options (such as Log5j) that take advantage of the latest Java language features. I'd recommend taking a long look Logback (from one of the main programmers of Log4j, as is slf4j).

这篇关于比较log4j和Logger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆