Java日志框架中有哪些最新选项? [英] What are the latest options in Java logging frameworks?

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

问题描述

这个问题会定期询问,但我一直认为现有的Java日志框架过于复杂和过度设计,我想看看有什么新内容。



我对当前项目有一个更为关键的问题,因为我们将JSON标准化为人类可读的数据编码,而且我见过的大多数日志框架都需要XML。我宁愿避免在95%的应用程序配置中使用JSON,而仅仅因为日志记录框架而使用XML(事实上,我不喜欢用于除文本标记以外的任何其他用途的XML)。



是否有任何热门的新Java日志框架,这些框架都是主动维护的,功能相当强大,有maven仓库,可以在不重新启动应用程序的情况下进行重新配置,并且不会将您绑定到XML ?

解决方案

您有3个选择:





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


  1. 积极维护

  2. 相当强大

  3. 有一个maven repo

  4. 可以是重新配置而不重新启动您的应用

  5. 不要将您绑定到XML

log4j


  1. ,不是积极维护

  2. 是 -

  3. 是 -

  4. -

  5. (使用Java属性文件,请参阅配置)。

java.util.logging (JUL)


  1. 我会说是 -

  2. 由您自行决定 -

  3. N / A -

  4. 是(通过JMX或 LogManager #readConfiguration() -

  5. 是(使用属性文件)



  6. Logback


    1. 是 -

    2. 是 -

    3. 是 -

    4. 是,通过 JMX autoScan -

    5. XML或Groovy中的配置文件

    看起来你必须做出一些让步(或找到一个我不知道的框架)。我会去 Logback ,这就是现在发生的事情。


    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.

    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).

    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?

    解决方案

    You have 3 options:

    • Log4J
    • java.util.logging (JUL)
    • Logback (the successor of Log4J)

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

    1. actively maintained
    2. reasonably powerful
    3. have a maven repo
    4. can be reconfigured without restarting your app
    5. don't tie you to XML

    log4j:

    1. No, not actively maintained
    2. Yes -
    3. Yes -
    4. Yes -
    5. Yes (using Java properties file, see Configuration).

    java.util.logging (JUL):

    1. I'd say Yes -
    2. at your discretion -
    3. N/A -
    4. Yes (via JMX or LogManager#readConfiguration() -
    5. Yes (using properties files)

    Logback:

    1. Yes -
    2. Yes -
    3. Yes -
    4. Yes, via JMX or autoScan -
    5. Configuration files in XML or Groovy

    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天全站免登陆