当前位置:网站首页>JCL learning
JCL learning
2022-07-30 10:12:00 【Rest in the summer】
The full name is Jakarta Commons Logging, which is a general log API provided by Apache.
It provides a unified interface for "all Java log implementations", and it also provides a log implementation, but the function is very weak (SimpleLog).So it is generally not used alone.He allows developers to use different specific log implementation tools: Log4j, Jdk's own log (JUL)
JCL has two basic abstract classes: Log (the base logger) and LogFactory (responsible for creating Log instances).

1. Getting started with JCL
- Build maven project
- Add dependency
commons-logging commons-logging 1.2 - Introduction code
public class JCLTest {@Testpublic void testQuick() throws Exception {// Get the log logger objectLog log = LogFactory.getLog(JCLTest.class);// output of logginglog.info("hello info");}}
Why do we use the log facade:
- Interface-oriented development, no longer depends on specific implementation classes.Reduce code coupling
- The project can flexibly switch the log framework by importing different log implementation classes
- Unified API, easy for developers to learn and use
- Unified configuration is convenient for project log management
2, JCL principle
1. Dynamically load the Log implementation class through LogFactory

2. An array of log implementations supported by the log facade
private static final String[] classesToDiscover =new String[]{"org.apache.commons.logging.impl.Log4JLogger","org.apache.commons.logging.impl.Jdk14Logger","org.apache.commons.logging.impl.Jdk13LumberjackLogger","org.apache.commons.logging.impl.SimpleLog"};3. Get the specific log implementation
for(int i = 0; i < classesToDiscover.length && result == null; ++i) {result = this.createLogFromClass(classesToDiscover[i], logCategory,true);}边栏推荐
猜你喜欢

多线程保证单个线程开启事务并生效的方案

STM32CubeMX配置生成FreeRTOS项目

ospf2双点双向重发布(题2)

An article to understand service governance in distributed development

leetcode 剑指 Offer 42. 连续子数组的最大和

百度paddleocr检测训练

JCL 学习

EViews 12.0 software installation package download and installation tutorial

线程池方式开启线程--submit()和execute()的区别

Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
随机推荐
Soft Exam System Architect Concise Tutorial | Case Analysis | Requirement Analysis
leetcode 剑指 Offer 25. 合并两个排序的链表
BERT预训练模型系列总结
leetcode 剑指 Offer 42. 连续子数组的最大和
Security思想项目总结
Multithreading--the usage of threads and thread pools
leetcode 剑指 Offer 57. 和为s的两个数字
105. 从前序与中序遍历序列构造二叉树(视频讲解!!)
Oracle 创建和操作表
(C语言)文件操作
Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
Meikle Studio - see the actual combat notes of Hongmeng equipment development five - drive subsystem development
mysql安装教程【安装版】
Using IN in MySQL will not go through index analysis and solutions
快解析结合用友时空
学习笔记11--局部轨迹直接构造法
你真的懂Redis的5种基本数据结构吗?
GNOME 新功能:安全启动被禁用时警告用户
Online target drone prompt.ml