当前位置:网站首页>How to configure log4j in slf4j?
How to configure log4j in slf4j?
2022-07-27 20:16:00 【qq_ twenty-five million seventy-three thousand two hundred and 】
from :
slf4j How to proceed in log4j Configuration ?
The following is about slf4j Middle configuration log4j Method sharing , As shown below :
Step one :pom.xml add to log4j rely on
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.25</version> </dependency> perhaps <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.8.0-alpha2</version> </dependency>
Step two : To configure log4j
log4j Configuration details log4j.xml Full profile or log4j.properties Detailed explanation of the complete configuration file
Test code
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoggerTest {
private static final Logger logger = LoggerFactory.getLogger(LoggerTest.class);
public static void main(String[] args) {
logger.fatal(" Fatal error ");
logger.error(" A serious warning ");
logger.info(" General information ");
logger.debug(" Debugging information ");
}
}
matters needing attention :
Here want to use SLF4J To write the code for logging
But can't use log4j Write a log
When you need to switch other logging frameworks, such as logback Just change the dependency 边栏推荐
- Overview of deep active learning 2020
- Wu Hequan: digital technology empowering "double carbon" practice according to local conditions
- If you want to switch to software testing, you should pass these three tests first, including a 3000 word super full test learning guide
- C193: scoring system
- 技术分享 | 接口自动化测试中,如何做断言验证?
- shell
- uva1377
- 一看就懂的ESLint
- 长安链数据存储源码分析
- set--数据解构
猜你喜欢

PyQt5快速开发与实战 4.7 QSpinBox(计数器) and 4.8 QSlider(滑动条)

Software configuration | tigervnc download, installation and configuration

Introduction to basic cesium controls

技术分享 | 接口自动化测试中,如何做断言验证?

codeforces每日5题(均1500)-第二十四天

Chemical giant BASF & Pasqual: using quantum neural network to optimize weather forecast

What does bus mean

TS2532: Object is possibly ‘undefined‘

Underlying principle of mvcc

办公自动化解决方案——DocuWare Cloud 将应用程序和流程迁移到云端的完整的解决方案
随机推荐
libpcap库和pcap_sendpacket接口函数了解
PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)
长安链数据存储源码分析
ES6--解构赋值
Konka sold out its first 100000 storage master chips, with an estimated sales volume of 100million in 2020
Introduction to reinforcement learning
Chapter 2 Introduction
如何快速提升抖音小店三分钟回复率?哪些情况会影响抖音小店回复率呢?
22 year PMP test [Quanzhen agile test]
Wu Hequan: digital technology empowering "double carbon" practice according to local conditions
Qtexttospeech class of QT realizes voice broadcast function
获得微店商品详情 API
C # network application programming, experiment 2: IP address translation and domain name resolution exercises
unity2D 动态漫画剧本(给猛虎桥章节做动画演示二)
ms721负载测试
一看就懂的ESLint
最新获得淘宝app商品详情原数据 的API
Rodin 安装 SMT Solvers 插件
MongoDB 学习笔记: BSON 结构分析
Libpcap library and pcap_ Sendpacket interface function understanding