With spring have to use, you will hear a lot of logs associated libraries, log4j
/ slf4j
/ common-logging
/ log4j-over-slf4j
, not too get to know them before logging system is in what to say, today saw the article ), to understand a lot.
First log system basic concept can be divided into two parts, one is the interface, it is a realization.
- Interface: the interface is called when the class how to call
- Implementation: log output logic function to achieve full give
Wherein slf4j
and common-logging
belonging to the interface.
log4j
And logback
belongs to achieve.
Specifically, common-logging
the interface and log4f
can be considered to generation, through common-logging
the interface, use log4j
.
And slf4j
the emergence of promising alternative common-logging
, also logback
a promising alternative log4j
.
slf4j
Corresponding to common-logging
the advantage of the interface, support for formatted log output parameters, not many +
plus stitching so.
And logback
the corresponding log4j
advantages should be on efficiency.
Others can see there are some, such as log4j-over-slf4j
this library is equivalent to log4j
adapt to the slf4j
interface, belongs to the adaptation layer between the interface layer and implementation layer.