首页 > 其他分享 >SLF4J warning or error messages and their meanings(转)

SLF4J warning or error messages and their meanings(转)

时间:2023-08-03 22:06:05浏览次数:38  
标签:meanings jar messages SLF4J log4j their slf4j org class

 

The method o.a.commons.logging.impl.SLF4FLogFactory#release was invoked.

Given the structure of the commons-logging API, in particular as implemented by SLF4J, the o.a.commons.logging.impl.SLF4FLogFactory#release()method should never be called. However, depending on the deployment of commons-logging.jar files in your servlet container, release() method may be unexpectedly invoked by a copy of org.apache.commons.logging.LogFactory class shipping with commons-logging.jar.

This is a relatively common occurrence with recent versions of Tomcat, especially if you place jcl-over-slf4j.jar in WEB-INF/lib directory of your web-application instead of $TOMCAT_HOME/common/lib, where $TOMCAT_HOME stands for the directory where Tomcat is installed. In order to fully benefit from the stability offered by jcl-over-slf4j.jar, we recommend that you place jcl-over-slf4j.jar in $TOMCAT_HOME/common/lib without placing a copy in your web-applications.

Please also see bug #22.

Operation [suchAndSuch] is not supported in jcl-over-slf4j.

An UnsupportedOperationException is thrown whenever one of the protected methods introduced in JCL 1.1 are invoked. These methods are invoked by LogFactory implementations shipping with commons-logging.jar. However, the LogFactory implemented by jcl-over-slf4j.jar, namely SLF4FLogFactory, does not call any of these methods.

If you observe this problem, then it is highly probable that you have a copy of commons-logging.jar in your class path overriding the classes shipping with jcl-over-slf4j.jar. Note that this issue is very similar in nature to the warning issued when the "o.a.commons.logging.impl.SLF4FLogFactory.release()" method is invoked, discussed in the previous item.

Detected logger name mismatch

Logger name mismatch warnings are printed only if the slf4j.detectLoggerNameMismatch system property is set to true. By default, this property is not set and no warnings will be printed even in case of a logger name mismatch.

SINCE 1.7.9 The warning will be printed in case the name of the logger specified via a class passed as an argument to theLoggerFactory.getLogger(Class) method differs from the name of the caller as computed internally by SLF4J.

For example, the following code snippet

package com.acme;
import com.foo.Kangaroo;

class Fruit {
  Logger logger = LoggerFactory.getLogger(Kangaroo.class);
}

will result in the warning

SLF4J: Detected logger name mismatch. Given name: "com.foo.Kangaroo"; computed name: "com.acme.Fruit".

but only if slf4j.detectLoggerNameMismatch system property is set to true.

No warning will be issued for the special case where the class in which the logger is defined is a super-type of the class parameter passed as argument. For example,

class A { 
    Logger logger = LoggerFactory.getLogger(getClass()); 
}
class B extends A { 
    // no mismatch warning will be issued when B is instantiated 
    // given that class A is a super-type of class B
}

If you come across a mismatch warning which cannot be explained, then you might have spotted a white elephant, that is a very rare occurrence where SLF4J cannot correctly compute the name of the class where a logger is defined. We are very interested to learn about such cases. If and when you spot an inexplicable mismatch, please do file a bug report with us.

Failed to load class org.slf4j.impl.StaticLoggerBinder

This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jarslf4j-simple.jarslf4j-log4j12.jarslf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

SINCE 1.6.0 As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.

You can download SLF4J bindings from the project download page.

Multiple bindings were found on the class path

SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.

When multiple bindings are available on the class path, select one and only one binding you wish to use, and remove the other bindings. For example, if you have both slf4j-simple-1.7.10.jar and slf4j-nop-1.7.10.jar on the class path and you wish to use the nop (no-operation) binding, then remove slf4j-simple-1.7.10.jar from the class path.

The list of locations that SLF4J provides in this warning usually provides sufficient information to identify the dependency transitively pulling in an unwanted SLF4J binding into your project. In your project's pom.xml file, exclude this SLF4J binding when declaring the unscrupulous dependency. For example, cassandra-all version 0.8.1 declares both log4j and slf4j-log4j12 as compile-time dependencies. Thus, when you include cassandra-all as a dependency in your project, the cassandra-all declaration will cause both slf4j-log4j12.jar and log4j.jar to be pulled in as dependencies. In case you do not wish to use log4j as the the SLF4J backend, you can instruct Maven to exclude these two artifacts as shown next:

<dependencies>
  <dependency>
    <groupId> org.apache.cassandra</groupId>
    <artifactId>cassandra-all</artifactId>
    <version>0.8.1</version>

    <exclusions>
      <exclusion> 
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
      </exclusion>
      <exclusion> 
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
      </exclusion>
    </exclusions> 

  </dependency>
</dependencies>

NOTE The warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random. As of version 1.6.6, SLF4J will name the framework/implementation class it is actually bound to.

Embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose. When you come across an embedded component declaring a compile-time dependency on any SLF4J binding, please take the time to contact the authors of said component/library and kindly ask them to mend their ways.

slf4j-api version does not match that of the binding

An SLF4J binding designates an artifact such as slf4j-jdk14.jar or slf4j-log4j12.jar used to bind slf4j to an underlying logging framework, say, java.util.logging and respectively log4j.

Mixing mixing different versions of slf4j-api.jar and SLF4J binding can cause problems. For example, if you are using slf4j-api-1.7.10.jar, then you should also use slf4j-simple-1.7.10.jar, using slf4j-simple-1.5.5.jar will not work.

NOTE From the client's perspective all versions of slf4j-api are compatible. Client code compiled with slf4j-api-N.jar will run perfectly fine with slf4j-api-M.jar for any N and M. You only need to ensure that the version of your binding matches that of the slf4j-api.jar. You do not have to worry about the version of slf4j-api.jar used by a given dependency in your project. You can always use any version of slf4j-api.jar, and as long as the version of slf4j-api.jar and its binding match, you should be fine.

At initialization time, if SLF4J suspects that there may be a api vs. binding version mismatch problem, it will emit a warning about the suspected mismatch.

Logging factory implementation cannot be null

This error is reported when the LoggerFactory class could not find an appropriate binding. Placing one (and only one) of slf4j-nop.jarslf4j-simple.jar,slf4j-log4j12.jarslf4j-jdk14.jar or logback-classic.jar on the class path should prove to be an effective remedy.

Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.

The purpose of slf4j-log4j12 module is to delegate or redirect calls made to an SLF4J logger to log4j. The purpose of the log4j-over-slf4j module is to redirect calls made to a log4j logger to SLF4J. If both slf4j-log4j12.jar and log4j-over-slf4j.jar are present on the class path, a StackOverflowError will inevitably occur immediately after the first invocation of an SLF4J or a log4j logger.

Here is how the exception might look like:

Exception in thread "main" java.lang.StackOverflowError
  at java.util.Hashtable.containsKey(Hashtable.java:306)
  at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:36)
  at org.apache.log4j.LogManager.getLogger(LogManager.java:39)
  at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:249)
  at org.apache.log4j.Category.<init>(Category.java:53)
  at org.apache.log4j.Logger..<init>(Logger.java:35)
  at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:39)
  at org.apache.log4j.LogManager.getLogger(LogManager.java:39)
  at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:249)
  at org.apache.log4j.Category..<init>(Category.java:53)
  at org.apache.log4j.Logger..<init>(Logger.java:35)
  at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:39)
  at org.apache.log4j.LogManager.getLogger(LogManager.java:39)

标签:meanings,jar,messages,SLF4J,log4j,their,slf4j,org,class
From: https://blog.51cto.com/u_15147537/6953460

相关文章

  • imessages群发,苹果imessages短信,苹果imessages推信,完美实现 - 电脑升级版
    一、PC电脑版苹果系统(MacOS)上实现imessages群发总结为以下几种方式:/*MacOS苹果系统,正常情况下,只能安装到苹果公司自己出品的Mac电脑,俗称白苹果,不能安装到各种组装机或者其他品牌的品牌机上,黑苹果的的原理,就是通过一些“破解补丁”工具欺骗macOS系统,让苹果系统认为你的电......
  • what is Enveloped Data Messages?
    from: CreatingandReceivingEnvelopedDataMessages-Win32apps|MicrosoftLearnAnenvelopedmessageisamessagethatisencryptedforasetofrecipients.Intheenvelopmentprocess,asessionencryptionkeyisgeneratedandthemessageisencrypted......
  • RocketMq5.0 任意延迟时间 TimerMessageStore 源码解析
    TimerMessageStore简略介绍延迟队列rmq_sys_wheel_timer指定时间的延迟消息。会先投递到rmq_sys_wheel_timer队列中然后由TimerMessageStore消费队列数据,将数据消费到timerWheel使用时间轮算法,实现秒级任务TimerMessageStore操作的文件store\consumequeue\rmq_sy......
  • linux系统-关于/var/log/messages系统日志文件
    日志信息各字段含义:1. 事件的日期和时间2. 事件的来源主机3. 产生这个事件的程序[进程号] 4. 实际的日志信息/var/log/messages日志格式从左到右分别是:月  日   时分秒   主机名   进程名 PID   日志内容......
  • 电脑版 - imessages群发,苹果imessages短信,苹果imessages推信,完美实现总结
    一、PC电脑版苹果系统(MacOS)上实现imessages群发总结为以下几种方式:/*MacOS苹果系统,正常情况下,只能安装到苹果公司自己出品的Mac电脑,俗称白苹果,不能安装到各种组装机或者其他品牌的品牌机上,黑苹果的的原理,就是通过一些“破解补丁”工具欺骗macOS系统,让苹果系统认为你的......
  • 苹果imessages短信,imessages群发,imessages短信,imessages推信,完美实现总结 - 电脑
    一、PC电脑版苹果系统(MacOS)上实现imessages群发总结为以下几种方式:/*MacOS苹果系统,正常情况下,只能安装到苹果公司自己出品的Mac电脑,俗称白苹果,不能安装到各种组装机或者其他品牌的品牌机上,黑苹果的的原理,就是通过一些“破解补丁”工具欺骗macOS系统,让苹果系统认为你的电......
  • 深入探讨struts的ActionMessages消息机制
     深入探讨struts的ActionMessages消息机制 版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处、作者信息和本声明。否则将追究法律责任。http://leaze.blog.51cto.com/83088/51750   在介绍ActionMessages前,我觉得有必要先介绍一下ActionMessages的数......
  • imessages数据检测,imessages过蓝检测,用applescript检测手机号码是否注册imessage实
    一、检测iMessage发送数据的2种方式:1.人工筛选,将要验证的号码输出到文件中,以逗号分隔。再将文件中的号码粘贴到iMessage客户端的地址栏,iMessage客户端会自动逐个检验该号码是否为iMessage账号,检验速度视网速而定。红色表示不是iMessage账号,蓝色表示iMessage账号。2.编写脚本控制......
  • ssh远程redhat6报错:Unable to negotiate with *.*.*.* port 22: no matching host key
    报错:Unabletonegotiatewith*.*.*.*port22:nomatchinghostkeytypefound.Theiroffer:ssh-rsa,ssh-dss分析:openssh觉得ssh-rsa加密方式不安全,直接从8.8开始默认不允许这种密钥用于登陆了 解决:cat/etc/ssh/ssh_config.d/redhat6.confHost*PubkeyAcceptedKe......
  • Linux操作系统日志审计-关于secure和messages两个重要的日志的logrotate配置
    关于Linux操作系统中有两个日志非常的重要的,常常用来对操作系统的活动进行审计,两个日志文件分别是:/var/log/secure/var/log/messages 其中/var/log/secure是 securityandauthentication-relatedmessagesanderrors,安全与认证相关的信息和错误对于 /var/log/messages......