Java Log frame
0 mainstream Java logging framework
Mainstream Java logging framework:
1.JUL - can not be divided into days and files, and is supported to be eliminated
2.log4j - old and mainstream log framework
Log facade frame
3.JCL - only supports JUL and log4j, which is obsolete
4.slf4j - the mainstream log framework in the market
5.logback - the default log implementation framework of springboot
6.log4j2 - log4j is rarely used after logback comes out, so apache launched log4j2, which is very similar to logback in function
Few people have log4j2 now. slf4j facade + log4j2 implementation should be the general trend in the future.
Historical order in which log frames appear:
log4j—>JUL---->JCL---->slf4j—>logback---->log4j2
apache (eliminated) (eliminated) log4j founder apache
(few people use it)
1 log4j
1.1 theoretical knowledge
1.1.1 Loggers loggers
Loggers logger ---- controls the output level of logs and whether logs are output
logger.fatal(“fatal”); // A serious error, which usually causes the system to crash and terminate the operation
logger.error(“error”); // The error message will not affect the system operation
logger.warn(“warn”); // Warning messages, problems may occur
logger.info(“info”); // Program running information
logger.debug(“debug”); // Debugging information is generally used in development,
Record the transfer information of program variable parameters
logger.trace(“trace”); // Track information and record all process information of the program
1.1.2 Appenders output
Appenders output - specifies the log output method (output to console, file)
ConsoleAppender outputs logs to the console
FileAppender outputs logs to a file (not meaningful)
Daily rollingfileappender splits and outputs logs to a log file by date,
And each output to a new file
RollingFileAppender splits by size and outputs log information to a log file,
And formulate the size of the document when the file size reaches the specified size
The file name will be changed automatically and a new file will be generated at the same time
The JDBC appender saves the log information to the database
1.1.3 Layout log formatter
Layout log formatter - controls the output format of log information
HTMLLayout html tabular form
SimpleLayout simple log output format info – message
PatternLayout's most powerful formatter typically uses this
General format is:% d{yyyy MM DD HH: mm: SS} [% - 5p]% R% l% m% n
2021-25-12 15:25:23 [INFO ]34 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:20) info
%p Output priority and debug,info %r Output from application startup to output log The number of milliseconds the message took %d The current time of the output server defaults to ISO08601 You can also specify a format, such as:%d{yyyy year MM month dd day HH:mm:ss}
% l the location where the output log occurs includes the class name, thread, and the number of lines in the code, such as test main(Test.java:10)
# %l = %c %t %F %L
% c output the full name of the class to which the print statement belongs
% t output the full name of the thread that generated the log
% F name of the file where the output log message was generated
% L number of lines in output code
%% outputs a '%' character
Log information specified in% m output code
% n line feed
% 5 width is 5 right justified
% - 5 width is 5 left justified
1.2 code implementation
1.2.1 maven dependency
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
1.2.2 log4j.properties
#Specifies the default configuration information of the RootLogger top-level parent element #Specify that the log level is = trace, and the appender used is = console console console # trace level console date info level date error level by size log4j.rootLogger = trace,console,dailyInfoFile,dailyErrorFile,rollingFile #Specifies the console log output appender object log4j.appender.console=org.apache.log4j.ConsoleAppender #Log output message format: SimpleLayout info--message, of which PatternLayout is most used log4j.appender.console.layout = org.apache.log4j.PatternLayout #Content standard format of specified message format:% d{yyyy MM DD HH: mm: SS} [% - 5p]% R% l% m% n log4j.appender.console.layout.conversionPattern =%d{yyyy-mm-dd HH:mm:ss} [%-5p]%r %l %m%n #Do not split, always a log file #Specifies the file log output appender object log4j.appender.file=org.apache.log4j.FileAppender #Log output message format: log4j.appender.file.layout = org.apache.log4j.PatternLayout #Specifies the content of the message format log4j.appender.file.layout.conversionPattern =%d{yyyy-mm-dd HH:mm:ss} [%-5p]%r %l %m%n #Specify the path to save the log file log4j.appender.file.file= /logs/log4j.log #Specifies the character set of the log file log4j.appender.file.encoding = UTF-8 #By date_ info_ split #Specifies the file log output appender object log4j.appender.dailyInfoFile=org.apache.log4j.DailyRollingFileAppender #Log output message format: log4j.appender.dailyInfoFile.layout = org.apache.log4j.PatternLayout #Specifies the content of the message format log4j.appender.dailyInfoFile.layout.conversionPattern =%d{yyyy-mm-dd HH:mm:ss} [%-5p]%r %l %m%n #Specify the path to save the log file log4j.appender.dailyInfoFile.file= /logs/daily_info.log #Specifies the character set of the log file log4j.appender.dailyInfoFile.encoding = UTF-8 #Splitting rules by specified date: 1 copy / day, 1 copy / hour log4j.appender.dailyInfoFile.datePattern = '.'yyyy-MM-dd HH-mm-ss #Output info level log to this file log4j.appender.dailyInfoFile.threshold = info #By date_ error_ split #Specifies the file log output appender object log4j.appender.dailyErrorFile=org.apache.log4j.DailyRollingFileAppender #Log output message format: log4j.appender.dailyErrorFile.layout = org.apache.log4j.PatternLayout #Specifies the content of the message format log4j.appender.dailyErrorFile.layout.conversionPattern =%d{yyyy-mm-dd HH:mm:ss} [%-5p]%r %l %m%n #Specify the path to save the log file log4j.appender.dailyErrorFile.file= /logs/daily_error.log #Specifies the character set of the log file log4j.appender.dailyErrorFile.encoding = UTF-8 #Splitting rules by specified date: 1 copy / day, 1 copy / hour log4j.appender.dailyErrorFile.datePattern = '.'yyyy-MM-dd HH-mm-ss #Output the error level log to this file log4j.appender.dailyErrorFile.threshold = error #Split by size #Specifies the file log output appender object log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender #Log output message format: log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout #Specifies the content of the message format log4j.appender.rollingFile.layout.conversionPattern =%d{yyyy-mm-dd HH:mm:ss} [%-5p]%r %l %m%n #Specify the path to save the log file log4j.appender.rollingFile.file= /logs/rollingFile.log #Specifies the character set of the log file log4j.appender.rollingFile.encoding = UTF-8 #Specifies the size of the log file contents log4j.appender.rollingFile.maxFileSize = 1MB #Specifies the number of log files log4j.appender.rollingFile.maxBackupIndex =10
1.2.3 Log4jTest.java
package com.tangguanlin.log; import org.apache.log4j.Logger; /** * Note: use of log4j * Author: Tang Guanlin * Date: 14:00, June 6, 2021 */ public class Log4jTest { public static void main(String[] args) { //Get logger object Logger logger = Logger.getLogger(Log4jTest.class); //Logging output //log level logger.fatal("fatal"); //A serious error, which usually causes the system to crash and terminate the operation logger.error("error"); //The error message will not affect the system operation logger.warn("warn"); //Warning messages, problems may occur logger.info("info"); //Program running information logger.debug("debug"); //Debugging information is generally used in development to record the transfer information of program variables and parameters logger.trace("trace"); //Track information and record all process information of the program } }
1.2. 4 operation results
2021-22-17 15:22:27 [FATAL]0 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:16) fatal 2021-22-17 15:22:27 [ERROR]5 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:18) error 2021-22-17 15:22:27 [WARN ]5 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:19) warn 2021-22-17 15:22:27 [INFO ]6 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:20) info 2021-22-17 15:22:27 [DEBUG]6 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:21) debug 2021-22-17 15:22:27 [TRACE]6 com.tangguanlin.log.Log4jTest.main(Log4jTest.java:23) trace
2 slf4j
2.1 theoretical knowledge
slf4j —Simple Logging Facade For Java
JUL - > not divided into days and files - > log4j - > change all the codes for different frameworks
--- > JCL (only support JUL and log4j) was eliminated by the market
slf4j
Log facade and log system
JCL has been eliminated - it only supports JUL and log4j. If the new logging method is used, it needs to reproduce and modify the code, which has been eliminated by the market
slf4j - mainstream log facade Technology
It is mainly to provide a set of standard and standardized API framework for Java log access. Its main significance is to provide interfaces. The specific implementation can be handed over to other log frameworks, such as log4j and logback. Of course, slf4j also provides a relatively simple implementation, but it is rarely used. For general Java projects, the logging framework will choose slf4j API as the facade,
With a specific implementation framework (log4j,logback), a bridge is used in the middle to complete the bridge.
Slf4j is the most popular log facade on the market. In current projects, slf4j is basically used as our log system.
Two functions:
1. Binding of log framework
2. Bridging of log frame
Log binding process using slf4j:
1. Add slf4j API dependencies
2. Use slf4j's API for unified logging in the project
3. Binding specific log implementation framework
(1). The binding has implemented slf4j's logging framework, and the corresponding dependencies are added directly
(2). Bind the log framework that does not implement slf4j. First add the log adapter, and then add the dependency of the implementation class
4.slf4j has only one log implementation framework binding
(if there are multiple dependencies, the first dependency log implementation is used by default)
Log bridging for slf4j:
slf4j-log4j12. The jar adapter is implemented using log4j
log4j-over-slf4j. The jar bridge is implemented by the slf4j facade instead of log4j
The adapter and bridge cannot appear at the same time, otherwise it will cause an endless loop.
2.2 slf4j log facade binding code
Specific implementation of slf4j interface facade + log4j
Specific implementation of slf4j interface facade + logback
2.2.1 maven dependency
<!--slf4j-api rely on--> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.26</version> </dependency> <!--log4j Adapter slf4j use log4j Adapter required--> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.12</version> </dependency> <!--log4j rely on--> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!--logback rely on--> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency>
2.2.2 Slf4jTest.java
package com.tangguanlin.log; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Note: use of slf4j * slf4j Facade + log4j concrete implementation * slf4j Concrete implementation of facade + logback * Author: Tang Guanlin * Date: 16:00, June 12, 2021 */ public class Slf4jTest { //Generate log object public static final Logger LOGGER = LoggerFactory.getLogger(Slf4jTest.class); public static void main(String[] args) { //Log output LOGGER.error("error"); LOGGER.warn("waring"); LOGGER.info("info"); //Default level LOGGER.debug("debug"); LOGGER.trace("trace"); //Output log information using placeholders String name ="zhangsan"; int age = 14; LOGGER.info("user:{},{}",name,age); try{ int i = 1/0; }catch(Exception e){ e.printStackTrace(); LOGGER.warn("Exception occurred:"+e); } } }
2.2. 3 operation results
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/01program_soft/01install_before/maven/localRepository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/01program_soft/01install_before/maven/localRepository/org/apache/activemq/activemq-all/5.15.8/activemq-all-5.15.8.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] [ERROR] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 18 [main] error [WARN ] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 19 [main] waring [INFO ] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 20 [main] info [DEBUG] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 21 [main] debug [TRACE] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 22 [main] trace [INFO ] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 27 [main] user:zhangsan,14 java.lang.ArithmeticException: / by zero at com.tangguanlin.log.Slf4jTest.main(Slf4jTest.java:30) [WARN ] 2021-12-17 15:25:22 com.tangguanlin.log.Slf4jTest main 33 [main] Exception occurred: java.lang.ArithmeticException: / by zero
2.3 slf4j log facade bridging code
Old projects are implemented with log4j
2.3.1 maven dependency
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
2.3.2 Log4jOverTest.java
package com.tangguanlin.log; import org.apache.log4j.Logger; /** * Description: log4j-over-slf4j Use of jar Bridge * Author: Tang Guanlin * Date: 17:00, June 12, 2021 */ public class Log4jOverTest { public static final Logger LOGGER = Logger.getLogger(Log4jOverTest.class); public static void main(String[] args) { LOGGER.info("log4j info"); System.out.println(11); } }
2.3. 3 remove log4j dependency
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
2.3. 4. Add facade frame dependency
<!--slf4j-api--> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.26</version> </dependency> <!--logback Log implementation--> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency> <!--log4j The original old log implementation code of the bridge does not need to be moved--> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>1.7.25</version> </dependency>
2.3.5 Log4jOverTest.java
package com.tangguanlin.log; import org.apache.log4j.Logger; /** * Description: log4j-over-slf4j Use of jar Bridge * Author: Tang Guanlin * Date: 17:00, June 12, 2021 */ public class Log4jOverTest { public static final Logger LOGGER = Logger.getLogger(Log4jOverTest.class); public static void main(String[] args) { LOGGER.info("log4j info"); System.out.println(11); } }
2.3. 6 operation results
2021-28-17 15:28:39 [INFO ]0 com.tangguanlin.log.Log4jOverTest.main(Log4jOverTest.java:14) log4j info 11
2.4 slf4j log configuration in springboot
To be added
2.5 slf4j log code in springboot
To be added
3 logback
3.1 theoretical knowledge
logback - also designed by the founder of log4j, its performance is better than log4j.
Logback is mainly divided into three modules:
. Logback core: the basic module of the other two modules
. Logback classic: it is an improved version of log4j, and it fully implements the slf4j API
. Logback access: the access module is integrated with the servlet container and provides the function of accessing logs through Http
logback configuration
. logback.grocvy
. logback-test.xml
. logback.xml
If none exists, the default configuration is used
1. Relationship between logback components
1.Logger: the logger of the log. After associating it with the corresponding context of the application, it is used to store the log object,
You can also define log types and levels
2.Appender: used to specify the destination of log output. The destination can be console, file, database, etc
3.Layout: it is responsible for converting time into string and outputting formatted log information.
In logback, the Layout object is encapsulated in the encoder.
Log output format: [%-5level] %d{yyyy-MM-dd HH:mm:ss} %c %M %L [%thread] %m%n %-5level log level %d{yyyy-MM-dd HH:mm:ss} Date format %c Is the full name of the class %M by method %L Is the line number %thread Is the thread name %m perhaps%msg For information %n Line feed
3.2 use of logback access
The logback access module is integrated with Servlet containers (such as Tomcat and Jetty) to provide HTTP access log function.
We can use the logback access module to replace the access log of tomcat.
1. Set logback access Jar and logback core Jar to $Tomcat_ Under home / lib /
2. Modify $Tomcat_ HOME/conf/server. Add to the Host element in XML:
<Valve className="ch.qos.logback.access.tomcat.LogbackValve" />
3.logback will be in $Tomcat by default_ Find the file logback access under home / conf xml
logback-access.xml configuration file
<?xml version="1.0" encoding="UTF-8"?> <configuration> <!-- always a good activate OnConsoleStatusListener --> <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/> <property name="LOG_DIR" value="${catalina.base}/logs"/> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_DIR}/access.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>access.%d{yyyy-MM-dd}.log.zip</fileNamePattern> </rollingPolicy> <encoder> <!-- Format of access log --> <pattern>combined</pattern> </encoder> </appender> <appender-ref ref="FILE"/> </configuration>
4. Official configuration: https://logback.qos.ch/access.html#configuration
3.3 code implementation
3.3.1 maven dependency
<!--slf4j Log facade--> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.26</version> </dependency> <!--logback Log implementation--> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency>
3.3.2 logback.xml
logback.xml configuration file
<?xml version="1.0" encoding="utf-8" ?> <configuration> <!-- Configure centralized management properties We can change the attribute directly value value format: ${name} --> <property name="pattern" value="[%-5level] %d{yyyy-MM-dd HH:mm:ss} %c %M %L [%thread] %m%n"></property> <!--Define log file save path attribute--> <property name="log_dir" value="/logs"></property> <!--Console log output appender--> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <!--Console output stream object default system.out Change to system.err--> <target>System.err</target> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>${pattern}</pattern> </encoder> </appender> <!--Log file output appender--> <appender name="file" class="ch.qos.logback.core.FileAppender"> <!--Log file save path--> <file>${log_dir}/logbak.log</file> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>${pattern}</pattern> </encoder> </appender> <!--Log splitting and archive compression appender object--> <appender name="rollFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!--Log file save path--> <file>${log_dir}/roll_logback.log</file> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>${pattern}</pattern> </encoder> <!--Specify split rules--> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <!--Declare the split file name in time and compression format--> <fileNamePattern>${log_dir}/roll_logback.%d{yyyy-MM-dd-HH-mm-ss}.log%i.gz</fileNamePattern> <!--Split by file size--> <maxFileSize>9012MB</maxFileSize> </rollingPolicy> <!--Log level filter--> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <!--Log filtering rules--> <level>WARN</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!--Asynchronous log--> <appender name="async" class="ch.qos.logback.classic.AsyncAppender"> <appender-ref ref="rollFile"></appender-ref> </appender> <!--root logger to configure--> <root level="All"> <!--log level--> <appender-ref ref="console"></appender-ref> <appender-ref ref="file"></appender-ref> <appender-ref ref="rollFile"></appender-ref> </root> </configuration>
3.3.3 LogbackTest.java
public static final Logger LOGGER = LoggerFactory.getLogger(LogbackTest.class); public static void main(String[] args) { for(int i=0;i<10;i++){ LOGGER.error("erroe"); LOGGER.warn("wring"); LOGGER.info("info"); LOGGER.debug("debug"); LOGGER.trace("trace"); } } }
3.3. 4 operation results
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/01program_soft/01install_before/maven/localRepository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/01program_soft/01install_before/maven/localRepository/org/apache/activemq/activemq-all/5.15.8/activemq-all-5.15.8.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace [ERROR] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 17 [main] erroe [WARN ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 18 [main] wring [INFO ] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 19 [main] info [DEBUG] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 20 [main] debug [TRACE] 2021-12-17 15:32:19 com.tangguanlin.log.LogbackTest main 21 [main] trace
4 log4j2
4.1 theoretical knowledge
To be added
4.2 implementation code
To be added