Home  >  Article  >  Java  >  Detailed introduction to the relationship between Java log components

Detailed introduction to the relationship between Java log components

不言
不言forward
2019-02-21 15:18:451817browse

This article brings you a detailed introduction to the relationship between Java log components. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Overview

This article does not evaluate the pros and cons of the log components, but only compares the relationships. There are several such relationships among the components in the log. A clear understanding of these relationships will help us introduce and use the log.

Detailed introduction to the relationship between Java log components

2. Log facade

The log facade refers to the log components that are directly introduced into our program to record logs. These components as the log facade will be used in the program There are several common log facade components listed in the figure above. For example, some software directly uses some components by default. For example, Spring uses commons-logging, and Activiti uses slf4j as the log facade. Other software will also choose the log facade that they think is useful.

3. Log implementation

In addition to log4j being both a facade and an implementation, both commons-logging and slf4j can print logs directly, and both need to rely on a log implementation to print logs. The above Several log implementations are also shown in the figure.

4. Bridging method

slf4j does some bridging processing with logback by default, so what is the role of bridging? If I want to use slf4j as the implementation facade, but at the same time I want to Use log4j as the real log implementation. At this time, you need the slf4j-logrj12 jar package. Now you should be able to understand the bridging method.

5. Change dependencies

The purpose here is to avoid some conflicts. For example, in this scenario, we use spring for development, and the software we develop uses slf4j as Log facade. At this time, because Spirng uses commons-logging as the log facade by default, some conflicts will occur at this time, so we can introduce jcl-over-slf4j to overwrite commons-logging through this component. In order to integrate historical software Internal dependencies are overwritten, and dependencies can be changed in this way.

The above is the detailed content of Detailed introduction to the relationship between Java log components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete