ActiveMQ与Logback日志组件SLF4J冲突导致日志不输出

2023-05-16

ActiveMQ与Logback中的SLF4J日志组件冲突导致日志不输出,控制台提示 Class path contains multiple SLF4J bindings 的解决方案。

近期码的时候发现logback的组件日志都没输出了,没有报错也就没去管它,直到排错越来越蛋疼……

查看控制台输出,当添加 ActiveMQ maven 依赖的时候日志就不输出了,并且提示


SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/apache/activemq/activemq-all/5.9.0/activemq-all-5.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/asus/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
  

很明显,组件冲突了,顺着控制台提示的链接去,有这么一大段说明:

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.13.jar and slf4j-nop-1.7.13.jar on the class path and you wish to use the nop (no-operation) binding, then remove slf4j-simple-1.7.13.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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
< 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 只能绑定到一个日志框架,如果在类路径发现多个绑定器,SLF4J 将警告并且列出这些绑定器。当有多个绑定器的时候SLF4J 将随机选择一个来使用,一般情况下可以在pom文件使用exclusion标签来排除冲突的日志组件,如上方的XML代码,不过在我这边就用不了这个方法了,先看看相关依赖代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!-- Log Support -->
< dependency >
     < groupId >org.slf4j</ groupId >
     < artifactId >slf4j-api</ artifactId >
     < version >1.7.5</ version >
</ dependency >
 
< dependency >
     < groupId >org.slf4j</ groupId >
     < artifactId >jcl-over-slf4j</ artifactId >
     < version >1.7.5</ version >
</ dependency >
 
 
< dependency >
     < groupId >ch.qos.logback</ groupId >
     < artifactId >logback-core</ artifactId >
     < version >1.0.13</ version >
</ dependency >
 
< dependency >
     < groupId >ch.qos.logback</ groupId >
     < artifactId >logback-classic</ artifactId >
     < version >1.0.13</ version >
</ dependency >
 
<!-- jms -->
< dependency >
     < groupId >org.apache.activemq</ groupId >
     < artifactId >activemq-all</ artifactId >
     < version >5.11.0</ version >
</ dependency >
< dependency >
     < groupId >org.springframework</ groupId >
     < artifactId >spring-jms</ artifactId >
     < version >4.1.4.RELEASE</ version >
</ dependency >

查看了eclipse的maven依赖目录才发现,activemq-all这个依赖直接把maven的全部组件给打成一个包了,其中就包括了导致冲突的日志组件,没办法了,只能一个个添加activemq的组件依赖了,修改后的activemq依赖配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!-- jms -->
< dependency >
     < groupId >org.apache.activemq</ groupId >
     < artifactId >activemq-core</ artifactId >
     < version >5.7.0</ version >
</ dependency >
< dependency >
     < groupId >org.apache.activemq</ groupId >
     < artifactId >activemq-pool</ artifactId >
     < version >5.13.0</ version >
</ dependency >
< dependency >
     < groupId >org.springframework</ groupId >
     < artifactId >spring-jms</ artifactId >
     < version >4.1.4.RELEASE</ version >
</ dependency >

ActiveMQ必备Jars说明:http://activemq.apache.org/initial-configuration.html#InitialConfiguration-RequiredJARs

重启tomcat,久违的日志出现…

来源:https://www.xssfox.com/2016-01-11/activemq%E4%B8%8Elogback%E6%97%A5%E5%BF%97%E7%BB%84%E4%BB%B6slf4j%E5%86%B2%E7%AA%81%E5%AF%BC%E8%87%B4%E6%97%A5%E5%BF%97%E4%B8%8D%E8%BE%93%E5%87%BA/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ActiveMQ与Logback日志组件SLF4J冲突导致日志不输出 的相关文章

  • OracleRAC管理 之 集群状态&信息查看

    OracleRAC管理 之 集群状态 amp 信息 查看 by 王磊 菜小小 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
  • fgetc,fgets,getline用法

    Linux Ubuntu 下用法 在Ubuntu下shell中 xff0c man fgets可以看到fgetc fgets等用法 xff0c man getline可以看到getline用法 span class hljs comment
  • 使用PyQt4制作一个音乐播放器(1)

    1 前言 最近用Python给老妈写了一个处理excel表格的小软件 xff0c 因为自己平时用Python一般都是用在数值计算领域 xff0c 所以一般使用命令行的方式交互即可 但是给老妈用发现用命令行交互方式使用并不是很方便 xff0c
  • ubuntu18.04/16.04 忘记开机密码,咋办?

    自己的 笔记本 装了双系统 xff0c 很久没有ubuntu系统了 xff0c 密码竟然给忘记了 于是乎 xff0c 在网上找答案 精髓 大概就是在句话 xff1a recovery nomodeset 并将之删除 xff0c 然后下移一行
  • C++ 实现阻塞队列

    文章出处 xff0c 来源自地址 xff1a C 43 43 实现阻塞队列 文章 详细代码 xff1a include lt queue gt include lt thread gt include lt mutex gt include
  • 浏览器请求nodejs搭建的web服务器上的html文件时引用不了jQuery.js文件解决办法

    构建web服务器代码 nodejs构建 span class token comment 引入核心模块http和fs span span class token keyword var span http span class token
  • AI 到底是怎么「想」的?

    本文作者 xff1a kurffzhou xff0c 腾讯 TEG 安全工程师 最近 xff0c Nature发表了一篇关于深度学习系统被欺骗的新闻文章 xff0c 该文指出了对抗样本存在的广泛性和深度学习的脆弱性 xff0c 以及几种可能
  • kafka3.1 docker-compose方式安装(二)

    ZooKeeper 是为 Kafka 提供协调服务的工具 xff0c 所以得启动一个ZooKeeper 容器 配置文件 docker compose yml span class token key atrule version span
  • 效能优化实践:C/C++单元测试万能插桩工具

    作者 xff1a mannywang xff0c 腾讯安全平台后台开发 研发效能是一个涉及面很广的话题 xff0c 它涵盖了软件交付的整个生命周期 xff0c 涉及产品 架构 开发 测试 运维 xff0c 每个环节都可能影响顺畅 高质量地持
  • Windows使用cmd刷入recovery.img

    Windows使用cmd刷入recovery img Windows键 43 R回车后进入cmd命令终端 进入fastboot 手机进入fastboot模式有2种方法 第一种进入方法是 xff0c 如果你的手机能用adb识别到 xff0c
  • Linux系统安装环境桌面

    最近工作加班还有在弄大数据 xff0c 有段时间没有记录了 xff0c 后续有空的话整理下大数据的东西分享 xff0c 今天记录下Linux安装环境桌面 之前弄了个阿里云服务器玩玩 xff0c CentOS 7的版本 xff0c CentO
  • 【Linux学习笔记】关于ubuntu开机菜单栏和任务栏不见了的有效解决方法

    一 问题描述 ubuntu开机只有桌面 xff0c 没有菜单栏和任务栏 xff0c 如下图 xff1a 二 问题解决 刚学习ubuntu xff0c 总有些像我这样不折腾就不舒服的人 xff0c 今天改了一下主题 xff0c 图标什么的 x
  • 【数据结构与算法】深入浅出递归和迭代的通用转换思想

    深入浅出递归和迭代的通用转换思想 一般来说 xff0c 能用迭代的地方就不要用递归 xff01 理论上讲 xff0c 所有的递归和迭代之间都能相互转换 xff01 刷题碰到 一天一道LeetCode 130 Surrounded Regio
  • 【unix网络编程第三版】阅读笔记(二):套接字编程简介

    unp第二章主要将了TCP和UDP的简介 xff0c 这些在 TCP IP详解 和 计算机网络 等书中有很多细致的讲解 xff0c 可以参考本人的这篇博客 计算机网络 第五版 阅读笔记之五 xff1a 运输层 xff0c 这篇博客就不再赘述
  • 带你深入理解STL之Deque容器

    在介绍STL的deque的容器之前 xff0c 我们先来总结一下vector和list的优缺点 vector在内存中是分配一段连续的内存空间进行存储 xff0c 其迭代器采用原生指针即可 xff0c 因此其支持随机访问和存储 xff0c 支
  • 带你深入理解STL之Set和Map

    在上一篇博客 带你深入理解STL之RBTree中 xff0c 讲到了STL中关于红黑树的实现 xff0c 理解起来比较复杂 xff0c 正所谓前人种树 xff0c 后人乘凉 xff0c RBTree把树都种好了 xff0c 接下来就该set
  • Redis源码剖析--字符串t_string

    前面一直在分析Redis的底层数据结构 xff0c Redis利用这些底层结构设计了它面向用户可见的五种数据结构 xff0c 字符串 哈希 xff0c 链表 xff0c 集合和有序集合 xff0c 然后用redisObject对这五种结构进
  • 制作启动盘安装Ubuntu 18.04.1

    1 使用UltraISO制作启动盘 首先 xff0c 下载Ubuntu镜像文件 链接 xff1a https pan baidu com s 1saIJuLzAR5ojc7 F3EQ Q 提取码 xff1a 1hc1 打开UItralISO
  • Redis源码剖析--快速列表quicklist

    在RedisObject这一篇博客中 xff0c 有介绍到list结构的底层编码类型有OBJ ENCODING QUICKLIST xff0c 当时就发现这个底层数据结构被我遗漏了 昨天花了点时间补了补这个知识 xff0c 看完发现这货就跟
  • Redis源码剖析--列表list

    上一篇博客Redis源码剖析 快速列表 带大家一起剖析了quicklist这个底层数据结构的实现原理 Redis对外开放的列表list结构就是采用quicklist作为底层实现 xff08 在新版本的Redis源码中 xff0c 不再采用z

随机推荐

  • lottie图片图层的json参数

    https juejin cn post 6992014666159357989
  • Android 各镜像文件img详解

    Android编译后生成文件 xff0c 在out target product xxx下 xff1a cache img cust img metadata img misc img xff08 本地无 xff09 recovery im
  • Android 10 来袭

    Android 10围绕三个重要主题构建 首先 xff0c Android 10正在塑造移动创新的领先优势 xff0c 具有先进的机器学习功能 xff0c 并支持新兴设备 xff0c 如可折叠和5G手机 接下来 xff0c Android
  • python代码规范 以及如何处理Pycharm的波浪号警告

    一 命名规范 1 模块名和包名采用小写字母并且以下划线分隔单词的形式 xff1b 如 regex syntax py compile winreg 2 类名或异常名采用每个单词首字母大写的方式 xff1b 如 xff1a BaseServe
  • java 两数相除 四舍五入 精确 保留2位小数点、任意位小数点

    java 四舍五入 精确 保留2位小数点 任意位小数点 int i 61 4 int j 61 14 float result 61 float i j java text DecimalFormat format 61 java text
  • 电脑关机或重启C盘数据被清空还原问题

    电脑关机后清空数据是因为电脑装有还原精灵 xff0c 可以下载冰点破坏工具 还原精灵破坏工具 硬盘保护卡破坏工具来取消数据的清空 电脑重启不还原 xff0c 方法如下 xff1a 方案一 一般情况下可以用带FDISK的启动盘启动电脑 xff
  • 敏捷教练的十种能力

    1 具备神奇的 读懂一个房间 的能力 只要走进一个房间 xff0c 就能判断出不在的过程中 xff0c 房间里发生了什么事情 xff0c 能立即读出空气中蕴含的情绪 xff0c 从而判断是否一切正常 xff1b 2 关心人本身胜过关心产品
  • Java数组之二分法查找数

    数组的二分法查找数据 使用前提 xff1a 查找的数组必须是有序的 span class token keyword public span span class token keyword class span span class to
  • MQ 队列管理器常见错误解析

    消息管理器无法连接到目标队列管理器 请确保以下事项 xff1a 在 消息管理器 队列管理器定义中所定义的端口与通道侦听器使用的端口相匹配 WebSphere MQ 队列管理器通道侦听器已启动 WebSphere MQ 队列管理器命令服务器已
  • 【简单理解】ubuntu中的sudo和su

    参考 xff1a https blog csdn net liberty12345678 article details 87686284 https cloud tencent com developer article 1721753
  • 那些女程序员们的故事

    点击上方蓝字 关注我们 xff0c 和小伙伴一起聊技术 xff01 程序媛是程序员大军中一道美丽的风景线 xff0c 今天的这篇文章就选取了一些女程序员们的故事 xff0c 希望当所有人了解了他们的经历后 xff0c 能让这个 重男轻女 的
  • 直播分享丨前沿技术讲习班:知识图谱前沿技术与应用(CIPS ATT27)

    本文转载自公众号 xff1a 智源社区助手 作为大数据时代重要的知识表示方式 xff0c 知识图谱是人工智能领域构建和应用知识的新阶段 xff0c 它能够更好地实现大规模数据的认知与推理 同时 xff0c 知识图谱和深度学习相互协作 xff
  • 图谱实战 | 京东基于时序知识图谱的问答系统

    转载公众号 DataFunSummit 分享嘉宾 xff1a 商超博士 京东硅谷研究院 研究员 编辑整理 xff1a 张存旺 北航杭州创新研究院 出品平台 xff1a DataFunTalk 导读 xff1a 本文将分享Temporal K
  • 肖仰华 | 基于知识图谱的问答系统

    本文转载自公众号知识工场 本文整理自复旦大学知识工场肖仰华教授在VLDB 2017 会议上的论文报告 xff0c 题目为 KBQA Learning Question Answering over QA Corpora and Knowle
  • 研讨会 | 知识图谱前沿技术课程暨学术研讨会(武汉大学站)

    知识图谱作为大数据时代重要的知识表示方式之一 xff0c 已经成为人工智能领域的一个重要支撑 4月 28日 xff0c 武汉大学信息集成与应用实验室 与 复旦大学知识工场实验室 联合举办 知识图谱前沿技术课程暨学术研讨会 xff0c 将结合
  • jdbc中Statement和PreparedStatement有什么区别?哪个性能更好?

    Statement和PreparedStatement的功能主要是对sql语句的执行 区别 xff08 1 xff09 Statement每执行一条sql语句就需要生成一条执行计划 xff0c 执行100条就需要100条执行计划Prepar
  • redis的特性

    redis的特性 承接上文redis入门篇 xff0c 本文具体介绍一下redis的特性 xff0c 以及与另外一个nosql数据库memcached的对比 一 redis的优点 根据上文 xff0c 我们知道redis的如下特性成为了他的
  • Ubuntu22.04安装windows字体

    找到C Windows目录 xff0c 将其中的Fonts文件夹拷贝至ubuntu中 将该文件夹放至ubuntu的 usr share fonts目录下面 xff0c 可用下列命令 span class token function sud
  • 阿里巴巴笔试题选解

    阿里巴巴笔试题选解 9月22日 xff0c 阿里巴巴北邮站 小题 xff1a 1 有三个结点 xff0c 可以构成多少种二叉树形结构 xff1f 2 一副牌52 张 去掉大小王 xff0c 从中抽取两张牌 xff0c 一红一黑的概率是多少
  • ActiveMQ与Logback日志组件SLF4J冲突导致日志不输出

    ActiveMQ与Logback中的SLF4J日志组件冲突导致日志不输出 xff0c 控制台提示 Class path contains multiple SLF4J bindings 的解决方案 近期码的时候发现logback的组件日志都