当前位置:网站首页>How does slf4j configure logback?
How does slf4j configure logback?
2022-07-27 07:49:00 【qq_ twenty-five million seventy-three thousand two hundred and 】
from :
slf4j How to do logback Configuration ?
slf4j brief introduction :
slf4j,simple logging facade for java Abbreviation , Translated into java Simple appearance log .slf4j It's an open source project , It provides us with a consistent API To use different logging frameworks , such as : java.util.logging,logback,log4j etc. .slf4j Enable users to embed the logging framework they want to use at runtime . You can see from the name , It actually uses facade Design patterns to achieve .
Use slf4j, There is only one mandatory dependency , Namely slf4j-api-x.x.x.jar, When we write code , Only use this jar In the bag API, The application finds the specific logging framework of the binding under the classpath at run time , And use the bound logging framework to perform actual logging operations , If no suitable binding is found under the classpath of the application ,slf4j By default, an implementation without any operation is used .
The following is about slf4j Middle configuration logback Method sharing , As shown below :
Step one :pom.xml add to logback rely on
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.2.3</version> </dependency>
Step two : To configure logback
logback Configuration details logback.xml Full profile
Write 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.error(" A serious warning ");
logger.warn(" Warning ");
logger.info(" General information ");
logger.debug(" Debugging information ");
}
}边栏推荐
- 【Day42 文献精读】A Bayesian Model of Perceived Head-Centered Velocity during Smooth Pursuit Eye Movement
- Error when connecting to MySQL: public key retrieval is not allowed [solution]
- Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community
- MySQL backup strategy
- MySQL table name area in Linux is not case sensitive
- An open source OA office automation system
- Jjwt generate token
- LeetCode56. 合并区间
- 「翻译」SAP变式物料的采购如何玩转?看看这篇你就明白了
- Okaleido ecological core equity Oka, all in fusion mining mode
猜你喜欢

Panabit SNMP configuration

Zero training platform course-1. SQL injection Foundation

Plato farm is expected to further expand its ecosystem through elephant swap

Convert objects to key value pairs

C#委托的使用案例

我是不是被代码给耽误了……不幸沦为一名程序员……

Can Linux install sqlserver

The first open source MySQL native HTAP database in China will be released soon! Look at the three highlights first, limited to the surrounding areas, waiting for you~

什么是真正的 HTAP ?(二)挑战篇

Bingbing's learning notes: classes and objects (middle)
随机推荐
MySQL table name area in Linux is not case sensitive
HU相关配置
DEMO:PA30 银行国家码默认CN 增强
Leetcode54. 螺旋矩阵
shell企业面试题练习
API 版本控制【 Eolink 翻译】
Comprehensive analysis of ADC noise-02-adc noise measurement method and related parameters
LeetCode56. 合并区间
大家节日快乐哈
Understanding and learning of node flow and processing flow in io
Solution to automatic disconnection of SSH link of Tencent ECS
【飞控开发基础教程4】疯壳·开源编队无人机-串口(光流数据获取)
模仿大佬制作的宿舍门禁系统(三)
The token verification of applet message push configuration failed. Please check and confirm
Shell Scripts相关
Lua有状态迭代器
shell循环练习
自动化测试的使用场景
C# 事件用法案例 订阅事件+=
【Golang】golang开发微信公众号网页授权功能