http://blog.sina.com.cn/s/blog_54eb26870100uynj.html

到SLF4J官方网站:http://www.slf4j.org/codes.html#log4j_version

有如下说明:

The trace level was added to log4j in version 1.2.12 released on August 29, 2005. The trace level was added to the SLF4J API in version 1.4.0 on May 16th, 2007. Thus, starting with SLF4J 1.4.0, the log4j binding for SLF4J requires log4j version 1.2.12 or above.

从上面的说明可以看出,SLF4J用到了log4j的 trace 级别。

下载slf4j包, http://www.slf4j.org/dist/slf4j-1.6.4.zip

打开源码文件:
slf4j-1.6.4\slf4j-log4j12\src\main\java\org\slf4j\impl\StaticLoggerBinder.java

发现有下面的定义:

import org.apache.log4j.Level;
.......

private StaticLoggerBinder() {
   
loggerFactory = new Log4jLoggerFactory();
    try {
     
Level level = Level.TRACE;
    } catch
(NoSuchFieldError nsfe) {
     
Util.report("This version of SLF4J requires
log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version");

}
  }

从上面看出,如果org.apache.log4j.Level 没有TRACE属性,会报错“This version of SLF4J requires log4j version 1.2.12 or
later. See also http://www.slf4j.org/codes.html#log4j_version

这个异常是由于Level类没有静态属性TRACE抛出的,
因此解决办法有两个:
1、找到org.apache.log4j.Level中定义了TRACE属性的jar包,经过查找,log4j-1.2.15
这个版本有定义。

2、用SLF4j中自定义的org.apache.log4j.Level类,它重写了Level类。
  
我用的版本是slf4j-1.6.4.zip,可以从官方下载,里面有个jar包:log4j-over-slf4j-1.6.4.jar

把这个jar包放入web-info/lib下面即可,同时,要保证log4j-over-slf4j-1.6.4.jar优先装载。

SLF4J versions 1.4.0 and later requires log4j 1.2.12 or later 终极解决的更多相关文章

  1. Wndows 下npm 安装依赖时出现错误:MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".

    当在Windows环境中使用npm install或者yarn 安装依赖时,可能会出现如下类似的错误: MSBUILD : error MSB4132: The tools version " ...

  2. this version of SLF4J requires log4j version 1.2.12 or later.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  3. windows server 2003 64x 读取office数据终极解决办法 The 'Microsoft.Jet.OLEDB.4.0' provider is not registered

    微软老子信了你的邪!      试了各种办法没有效果 网友解决办法一: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the ...

  4. VC++6.0 下配置 pthread库2010年12月12日 星期日 13:14VC下的pthread多线程编程 转载

    VC++6.0 下配置 pthread库2010年12月12日 星期日 13:14VC下的pthread多线程编程     转载 #include <stdio.h>#include &l ...

  5. Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fa980000, 59244544, 0) failed; error='Cannot allocate memory' (errno=12)

    启动项目报错 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fa980000, 592445 ...

  6. OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Out of memory' (errno=12)

    使用docker 安装kafka时启动失败 查看报错日志 # docker logs --since 30m 71846a96e514 Excluding KAFKA_HOME from broker ...

  7. Vue2.0 【第一季】第3节 v-for指令:解决模板循环问题

    目录 Vue2.0 [第一季] 第3节 v-for指令:解决模板循环问题 第三节 v-for 指令 一.基本用法: 二.排序 三.对象循环输出 Vue2.0 [第一季] 第3节 v-for指令:解决模 ...

  8. make[2]: *** No rule to make target `/root/.pyenv/versions/anaconda3-2.4.0/lib/libpython3.5m.so', needed by `evaluation.so'. Stop.

    当出现No rule to make target ,肯定是Makefile有问题. 有的makefile是脚本生成的,你得看脚本的配置文件对不对. 我的是这个脚本生成的.发现是Pythondir的配 ...

  9. java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext问题原因及解决方法

    一.错误信息 java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logb ...

随机推荐

  1. margin-bottom无效问题以及div里内容动态居中样式!

    最近调前端样式时候,遇到一个需求,在中间文字不对等的情况下想让下面的操作文字距离底部对齐,如图: , 刚开始觉得使用margin-bottom就可以,后来发现只有margin-top是管用的,查了资料 ...

  2. 【codeforces】【比赛题解】#861 CF Round #434 (Div.2)

    本来是rated,现在变成unrated,你说气不气. 链接. [A]k-凑整 题意: 一个正整数\(n\)的\(k\)-凑整数是最小的正整数\(x\)使得\(x\)在十进制下末尾有\(k\)个或更多 ...

  3. MySQL修改datadir目录

    更改MySQL的数据目录由/usr/local/mysql/data/更换至/data/mysql/ 第一种方法修改my.cnf 1)关闭MySQL [root@test2 ~]# service m ...

  4. Python Challenge 第 5 关攻略:peak

    # -*- coding: utf-8 -*- # @Time : 2018/9/26 14:03 # @Author : cxa # @File : pickledemo.py # @Softwar ...

  5. 自动化测试Robotium获取当前页面的activity,用于判断是否进入这个页面

    一.启动app 二.进入命令行窗口输入 adb shell “dumpsys activity activities | grep mFocusedActivity” 三.断言方法 assertTru ...

  6. java基础66 JavaScript中的事件、localtion对象、screen对象(网页知识)

    1.JavaScript中的事件注册 1.1.事件的注册方式 方式1:直接在html元素上注册 <body onLoad="ready()"></body > ...

  7. java基础17 模板模式

    1.模版模式 解决某类事物的步骤有些是固定的,有些会发生改变的,那么这个时候我们可以为这一类事物提供一个模版代码,从而提高效率. 2.模版模式的步骤 1.先写出解决该类事物的其中一种解决方案;     ...

  8. C++两个类相互包含引用的问题

    在构造自己的类时,有可能会碰到两个类之间的相互引用问题,例如:定义了类A类B,A中使用了B定义的类型,B中也使用了A定义的类型 class A { B b; } class B { A* a; } 请 ...

  9. 一步一步学习IdentityServer3 (14) 启用Https

    申领一个CA证书,我用了一个腾讯的免费证书night-c.cn,这是腾讯云买域名送的一个证书 是单域名,非泛域名 1:安装证书  IIS选择证书 2:将证书加载到Identityserver3中,并启 ...

  10. GUC-7 同步锁 Lock

    import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /* * 一.用于解决 ...