问题描述
这个问题会定期被问到,但我一直觉得现有的 Java 日志框架过于复杂和过度设计,我想看看有什么新的.
This question gets asked periodically, but I've long felt that existing Java logging frameworks were overcomplicated and over-engineered, and I want to see what's new.
我目前的项目有一个更关键的问题,因为我们已将 JSON 标准化为人类可读的数据编码,而且我见过的大多数日志框架都需要 XML.我真的宁愿避免将 JSON 用于 95% 的应用程序配置,而将 XML 用于其余部分,只是因为日志记录框架(说实话,我讨厌将 XML 用于文本标记以外的任何东西,这是它最初的预期目的).
I have a more critical issue on my current project as we've standardized on JSON as our human-readable data encoding, and most logging frameworks I've seen require XML. I would really rather avoid using JSON for 95% of my apps configuration, and XML for the rest just because of the logging framework (truth be told, I hate XML used for anything other than text markup, its original intended purpose).
是否有任何热门的新 Java 日志框架得到积极维护、相当强大、具有 maven 存储库、无需重新启动应用即可重新配置、并且不将您绑定到 XML?
Are there any hot new Java logging frameworks that are actively maintained, reasonably powerful, have a maven repo, can be reconfigured without restarting your app, and don't tie you to XML?
推荐答案
你有 3 个选项:
- Log4J
- java.util.logging(七月)
- Logback(Log4J的继承者)
- Log4J
- java.util.logging (JUL)
- Logback (the successor of Log4J)
现在,让我们看看它们如何满足您的要求:
Now, let's see how they meet your requirements:
- 积极维护
- 相当强大
- 有一个 Maven 仓库
- 无需重启应用即可重新配置
- 不要把你束缚在 XML 上
log4j
:
- 否,未积极维护
- 是的 -
- 是的 -
- 是 -
- 是(使用 Java 属性文件,请参阅配置).李>
- No, not actively maintained
- Yes -
- Yes -
- Yes -
- Yes (using Java properties file, see Configuration).
java.util.logging
(七月):
java.util.logging
(JUL):
- 我会说是的 -
- 由您自行决定 -
- 不适用 -
- 是(通过 JMX 或
LogManager#readConfiguration()
- - 是(使用属性文件)
回退:
- 是的 -
- 是的 -
- 是的 -
- 是的,通过 JMX 或 autoScan -
- XML 或 Groovy 中的配置文件
- Yes -
- Yes -
- Yes -
- Yes, via JMX or autoScan -
- Configuration files in XML or Groovy
看起来你必须做出一些让步(或者找到一个我不知道的框架).我会选择 Logback,这就是现在发生的事情.
It looks like you'll have to make some concessions (or find a framework I'm not aware of). I would go for Logback, this is where things happen now.
这篇关于Java 日志框架的最新选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!