The full name of slf4j is simple login facade for Java, that is, it is only a unified interface that provides log output for Java programs, not a specific log implementation scheme. Like JDBC, it is just a rule. Therefore, slf4j alone cannot work. It must be combined with other specific log implementation schemes, such as org.apache.log4j.logger of Apache, java.util.logging.logger of JDK, etc.
Log4j is an open source project of Apache. By using log4j, we can control that the destinations of log information transmission are console, files, GUI components, even socket server, NT event recorder, UNIX syslog daemon, etc; We can also control the output format of each log; By defining the level of each log information, we can control the log generation process in more detail.
Log4j consists of three important components: loggers, Appenders and layout.
1. Logger: controls which logging statements to enable or disable, and limits the level of log information
2. Appenders: Specifies whether the log will be printed to the console or to a file
3. Layout: controls the display format of log information
Log4j defines five levels of log information to be output, namely debug, info, warn, error and fatal. When outputting, only information with a level higher than the level specified in the configuration can be really output, so it is convenient to configure the content to be output under different conditions without changing the code.
In short, logback is a logging framework in the Java field. It is considered the successor of log4j. Logback is mainly composed of three modules: logback core and logback classic. Logback access and logback core are the infrastructure of other modules, and other modules are built on it. Obviously, logback core provides some key functions
Logback classic has the same status and function as log4j. It is also considered as an improved version of log4j, and it implements a simple log facade slf4j;
Logback access is mainly used as a module to interact with servlet container, such as Tomcat or jetty, and provides some functions related to HTTP access.
With the same code path, logback executes faster
More adequate testing
Slf4j API is implemented natively (log4j also needs an intermediate conversion layer)
Support XML or groovy configuration
Automatic hot loading of configuration files
Recover gracefully from Io errors
Automatically delete log archive
Automatically compress logs into archive files
Support the student mode, so that multiple JVM processes can record the same log file
It supports adding condition judgment in the configuration file to adapt to different environments
More powerful filters
Supports siftingappender (filterable appender)
Exception stack information contains packet information
Elk is the abbreviation of elasticsearch, logstash and kibana. These three software and their related components can build a large-scale log real-time processing system.
- Elasticsearch is a Lucene based distributed storage and indexing engine that supports full-text indexing. It is mainly responsible for indexing and storing logs to facilitate business retrieval and query.
- Logstash is a middleware for log collection, filtering and forwarding. It is mainly responsible for uniformly collecting and filtering various logs of each business line, and forwarding them to elasticsearch for further processing.
- Kibana is a visualization tool, which is mainly responsible for querying elasticsearch data and presenting it to the business party in a visual way, such as various pie charts, histograms, area charts, etc.
This work adoptsCC agreement, reprint must indicate the author and the link to this article