本文介绍了Log4j是否被抛弃而支持Slf4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎log4j有一些(等等)在我看来,趋势是从log4j移出slf4j。 (Hibernate停止使用第一个支持后者)

It seems that log4j has some class loading issues (among others) and it seems to me the trend is to move out of log4j toward slf4j. (Hibernate stopped using the first in favor of the latter)


  1. 这是真的吗?

  2. 什么是stlf4j解决的log4j中的主要问题吗?

  3. slf4j是最后一个字还是更好的下一个下一个log4j行业标准?

更新:


  • 所以这个让我感到困惑,你能接受/反对吗?:

  • So this answer by delfuego confuses me, can you accept / object it?:




  • log4j的更多类加载问题:

    • More classloading issues by log4j: http://articles.qos.ch/classloader.html
    • 推荐答案

      Slf4j确实只是一个日志记录。但是,Log4j旨在由来自同一作者的继承。

      Slf4j is indeed just a logging facade. However, Log4j is intended to be succeeded by Logback, from the very same authors.

      更新:如果您想了解Slf4j的另一个好处,那就是不再需要以下(丑陋)构造来避免<$ strong c $ c> toString()不必要地被调用:

      Update: if you'd like to know about another benefit of Slf4j, it's the fact that following (ugly) constructs aren't needed anymore to avoid the toString() unnecessarily been called:

      if (logger.isDebugEnabled()) {
          logger.debug("Message: " + bigObject + ", " + anotherBigObject);
      }
      

      您可以改为使用参数化消息:

      You can instead make use of parameterized messages:

      logger.debug("Message: {}, {}", bigObject, anotherBigObject);
      

      另见

      这篇关于Log4j是否被抛弃而支持Slf4j?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:45
查看更多