技术控

    今日:41| 主题:49101
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Is Standard Java Logging Dead? Log4j vs Log4j2 vs Logback vs java.util.logging

[复制链接]
给我一颗糖 发表于 3 天前
18 0

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

Is Standard Java Logging Dead? Log4j vs Log4j2 vs Logback vs java.util.logging-1 (statements,recently,standard,explore,another)

  The Java log levels showdown: SEVERE FATAL ERROR OMG PANIC

   Capitalized log levels induce high levels of stress. What if, instead of ERROR we’d just use “oops”? On a more serious note, we’ve recently ran a huge data crunch over GitHub’s top Java projects and the logging statements they use , revealing the log level breakdown of the average Java project.
  In this post, we’ll explore the resulting data set from another angle, shed some more light on the dataset, and put the focus on the use of standard java.util.logging levels versus more popular frameworks like Log4j (+ Log4j 2), and Logback.
  Step right in.
   New Post: Is Standard Java Logging Dead? Log4j vs Log4j2 vs Logback vs java.util.logging https://t.co/cxIOCe0gWd pic.twitter.com/BmKIUIIDb4
   — OverOps (@overopshq) November 29, 2016
  Meet the players

  Logging utilities can be roughly divided to 2 categories: the logging facade and the logging engine.
   As far as logging facades go, you pretty much have 2 choices: slf4j and Apache’s commons-logging. In practice, 4 out of 5 Java projects choose to go with slf4j . Based on data from the top Java libraries in 2016 on Github . The motivation for using a logging facade is pretty definitive and straightforward, an abstraction on top of your logging engine of choice – allowing you to replace it without changing the actual code and logging statements.
   As to the logging engine, the most popular picks are Logback, which is an evolved version of Log4j , Log4j itself, and its new version since the development was passed on to the Apache Software Foundation, Log4j2. Trailing behind is Java’s default logging engine, java.util.logging aka JUL.
  Pointing fingers and calling names

  On the “superficial” side of things, each of the logging frameworks has slightly different names for their logging levels.

Is Standard Java Logging Dead? Log4j vs Log4j2 vs Logback vs java.util.logging-2 (statements,recently,standard,explore,another)

  In the rare case where slf4j is used with java.util.logging, the following mapping takes place:
  FINEST -> TRACE
  FINER -> DEBUG
  FINE -> DEBUG
  INFO -> INFO
  WARNING -> WARN
  SEVERE -> ERROR
  Another thing to notice here is that Logback and java.util.logging have no FATAL equivalent. Behind those error names, are simple integer values, that help control the logging level in a running applications. Each library also contains values for OFF and ALL, which basically set the logger level to actually transmit everything, or nothing. Setting a logger level at WARN for instance, would only log WARN messages and above – Its practically the default setting for production environments.
   btw, one of the cool things about the tool that we’re building , is that you can get log messages lower than WARN in production, even if you’ve set the logger level to WARN . Check out this video for a quick (25 sec) demonstration .
  How does the level naming breakdown look in practice?

  For the data crunch, we focused on the top starred Java projects with at least 100 logging statements in either of the methods. Examining the data set of projects, here’s what we found:
123下一页
友荐云推荐




上一篇:Early detection of configuration errors to reduce failure damage
下一篇:Della – Django App to Manange Secret Santa/Gift Exchange
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表