当前位置:网站首页>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 ");
}
}边栏推荐
- Understanding and learning of node flow and processing flow in io
- npm的使用
- Resttemplate connection pool configuration
- MCU multi-level menu
- User unlock sm04 sm12
- [day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement
- Shell loop exercise
- Temperature and humidity measurement and display device based on Arduino
- Systematic explanation of unit testing: mockito
- What about idea Chinese garbled code
猜你喜欢

MySQL backup strategy

DEMO SUBMIT 某程序并获取该程序ALV数据

一体化实时HTAP数据库StoneDB,如何替换MySQL并实现近百倍分析性能的提升

【小程序】uniapp发行微信小程序上传失败Error: Error: {'errCode':-10008,'errMsg':'invalid ip...

综合案例、

Zero training platform course-1. SQL injection Foundation

浅谈数据安全

RPC remote procedure call

DASCTF2022.07赋能赛密码wp

Day111.尚医通:集成NUXT框架、前台页面首页数据、医院详情页
随机推荐
opengl-shader学习笔记:varying变量
[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement
Bash: sudo: command not found in container
Use Amazon dynamodb and Amazon S3 combined with gzip compression to maximize the storage of player data
单片机多级菜单
Abstract factory pattern
浅谈数据安全
Flynk de duplication (2) solve the hot issues in the process of flynk and flynk SQL de duplication
[stonedb class] introductory lesson 1: popular science of database knowledge
[resolved] the new version of pychart (2022) connects to the server to upload files and reports an error of "command Rsync is not found in path", and the files cannot be synchronized
大家节日快乐哈
C language implementation of guessing numbers Games project practice (based on srand function, rand function, switch statement, while loop, if condition criterion, etc.)
Comprehensive analysis of ADC noise-02-adc noise measurement method and related parameters
Clickhouse notes 1 | introduction, features | installation and use based on centos7 system | common data types | mergetree table engine | SQL operation
DEMO:PA30 银行国家码默认CN 增强
小程序支付管理-新版支付对接流程
Summary of several common ways to join dimension tables in Flink
Systematic explanation of unit testing: mockito
Demo submit a program and obtain ALV data of the program
Understanding and learning of properties class and properties configuration file