Slf4j-api 1.x升级到2.x遇到的问题以及解决方案

原始依赖版本,这个是log4j2与slf4j的打印日志黄金组合。


            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.36</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>2.20.0</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.20.0</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.20.0</version>
            </dependency>

本来日志打印的好好的,但是slf4j-api 1.7.36马上要过期了。需要升级到slf4j-api 2.0.7最新版本。

但是如果只升级slf4j-api到2.0版本,将会无法打印日志。

因为slf4j-api 2.0之后,绑定方式将不是static bind,而是 spi ,需要Provider。机制不一样,所以桥接器org.apache.logging.log4j:log4j-slf4j-impl也需要更换了,

更换为:org.apache.logging.log4j:log4j-slf4j2-impl。


            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>2.0.7</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j2-impl</artifactId>
                <version>2.24.1</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.24.1</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.24.1</version>
            </dependency>

参考文献:

slf4j :SLF4J FAQ

版本配套:SLF4J 2.X 版本升级相关问题-优快云博客

我要重新下载安装hbase应该怎么做,我的配置是[manager1@hadoop102 module]$ ls flume-1.9.0 hadoop-3.3.6 hive-3.1.2 jdk8u452-b09 kafka-3.5.2 openssl-1.1.1v spark-3.5.3-bin-hadoop3 zookeeper-3.8.4 hadoop hbase-2.4.18 jdk-11.0.26 kafka_2.13-3.9.1 mysql-8.0.40-linux-glibc2.28-aarch64 Python-3.9.7 sparkapp [manager1@hadoop102 module]$ manager1@hadoop102 kafka_2.13-3.9.1]$ bin/kafka-topics.sh --version 3.9.1我要的hbase需要适配我的配置,我现在的hbase会出现错误:java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.hdfs.protocol.HdfsFileStatus, but class was expected 和SLF4J: Actual binding is of type [org.slf4j.impl.Reload4jLoggerFactory] SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.3.6/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/module/hbase-2.4.18/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.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.Reload4jLoggerFactory] hadoop102: running zookeeper, logging to /opt/module/hbase-2.4.18/logs/hbase-manager1-zookeeper-hadoop102.out hadoop103: running zookeeper, logging to /opt/module/hbase-2.4.18/logs/hbase-manager1-zookeeper-hadoop103.out hadoop104: running zookeeper, logging to /opt/module/hbase-2.4.18/logs/hbase-manager1-zookeeper-hadoop104.out hadoop102: SLF4J: Class path contains multiple SLF4J bindings. hadoop102: SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.3.6/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] hadoop102: SLF4J: Found binding in [jar:file:/opt/module/hbase-2.4.18/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.jar!/org/slf4j/impl/StaticLoggerBinder.class] hadoop102: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. hadoop102: SLF4J: Actual binding is of type [org.slf4j.impl.Reload4jLoggerFactory] running master, logging to /opt/module/hbase-2.4.18/logs/hbase-manager1-master-hadoop102.out hadoop102: running regionserver, logging to /opt/module/hbase-2.4.18/logs/hbase-manager1-regionserver-hadoop102.out hadoop104: regionserver running as process 5855. Stop it first. hadoop103: regionserver running as process 6486. Stop it first. [manager1@hadoop102 module]$ 一会hmaster就自动结束了,还有缺少hadoop-thirdparty-3.2.4.jar包的,我需要能解决这些问题的hbase版本
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值