Java 日志框架的最新选项是什么? [英] What are the latest options in Java logging frameworks?

查看:26
本文介绍了Java 日志框架的最新选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题会定期被问到,但我一直觉得现有的 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 (JUL)
  • Logback (the successor of Log4J)

现在,让我们看看它们如何满足您的要求:

Now, let's see how they meet your requirements:

  1. 积极维护
  2. 相当强大
  3. 有一个 Maven 仓库
  4. 无需重启应用即可重新配置
  5. 不要把你束缚在 XML 上

log4j:

  1. ,未积极维护
  2. 是的 -
  3. 是的 -
  4. -
  5. (使用 Java 属性文件,请参阅配置).李>
  1. No, not actively maintained
  2. Yes -
  3. Yes -
  4. Yes -
  5. Yes (using Java properties file, see Configuration).

java.util.logging(七月):

java.util.logging (JUL):

  1. 我会说是的 -
  2. 由您自行决定 -
  3. 不适用 -
  4. 是(通过 JMX 或 LogManager#readConfiguration() -
  5. 是(使用属性文件)

回退:

  1. 是的 -
  2. 是的 -
  3. 是的 -
  4. 是的,通过 JMXautoScan -
  5. XML 或 Groovy 中的配置文件
  1. Yes -
  2. Yes -
  3. Yes -
  4. Yes, via JMX or autoScan -
  5. 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 日志框架的最新选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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