当前位置:网站首页>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 ");
}
}边栏推荐
- Leetcode54. 螺旋矩阵
- An open source OA office automation system
- 面试复盘五
- SQL labs SQL injection platform - level 1 less-1 get - error based - Single Quotes - string (get single quote character injection based on errors)
- Flink1.14 SQL basic syntax (I) detailed explanation of Flink SQL table query
- Help send a recruitment, base all over the country. If you are interested, you can come and have a look
- Codeforces Round #810 (Div.2) A-C
- 孙子出题难,儿子监考严。老子不会做,还我上学钱
- shell 函数和数组练习
- C# 中的转译字符'/b'
猜你喜欢
随机推荐
C语言:随机生成数+插入排序
Temperature and humidity measurement and display device based on Arduino
为啥国内大厂都把云计算当成香饽饽,这个万亿市场你真的了解吗
Flink1.14 SQL basic syntax (I) detailed explanation of Flink SQL table query
帮个忙呗~不关注不登录,不到一分钟的一个问卷
Cadence (XI) silk screen printing adjustment and subsequent matters
JS regular expression implementation adds a comma to every three digits
容器内使用sudo报错bash: sudo: command not found解决
【飞控开发基础教程4】疯壳·开源编队无人机-串口(光流数据获取)
shell企业面试题练习
软件调优方法有哪些?看看飞腾技术专家怎么说 | 龙蜥技术
【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
DASCTF2022.07赋能赛密码wp
物联网工业级UART串口转WiFi转有线网口转以太网网关WiFi模块选型
C language programming | program compilation and preprocessing
[golang learning notes 2.0] arrays and slices in golang
Comprehensive analysis of ADC noise-01-types of ADC noise and ADC characteristics
Comprehensive analysis of ADC noise-02-adc noise measurement method and related parameters
C language implementation of guessing numbers Games project practice (based on srand function, rand function, switch statement, while loop, if condition criterion, etc.)
[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement









