Installation and configuration explanation of Log4j and Log4j2

What is a log? A log is a file that records detailed information about events or behaviors that occur when a system or application is running. It usually includes information such as timestamp, event type, event description, etc., so that troubleshooting, performance optimization, security auditing, etc. can be performed when needed. Logs can help developers […]

Exception, log framework (log4j2)

1. Exception 1. Concept An abnormal event occurs during the running of the program and the event can be handled. It will interrupt the running program. 2. Classification Error: represents a system-level error (a serious problem) Once a problem occurs in the system, Sun will encapsulate these errors into Error objects. Exception: represents possible problems […]

Log4j2 principle analysis and vulnerability recurrence

Log4j2 principle analysis and vulnerability reproduction 0x01 log4j2 introduction Log4j2 is a mature and powerful logging framework for Java applications. It is an upgraded version of Log4j. Compared with Log4j, Log4j2 has significant improvements in performance, reliability and flexibility. Log4j2 Features High performance: Log4j2 uses an asynchronous logging mechanism that can provide higher throughput and […]

Java logging system Log4j2

Introduction to Log4j2 Log4j2 is an upgraded version of Log4j. It refers to the excellent design of Logback and fixes some problems. The main advantages are: Exception handling. In logback, exceptions in Appender will not be perceived by the application, but in log4j2, some exception handling mechanisms are provided. Performance improvement, log4j2 has obvious performance […]

High-performance log desensitization component: already supports log4j2 and logback plug-ins

Project introduction Log desensitization is a common security requirement. The ordinary method based on tool class methods is too intrusive to the code and is particularly troublesome to write. Sensitive provides an annotation-based approach and has built-in common desensitization methods to facilitate development. It also supports common log desensitization plug-ins such as logback and log4j2. […]

Can’t handle the log? Teach you step by step how to use Log4j2

Todaywewillexplainoneoftheyoungestlogplug-ins,namelyLog4j2.Log4j2iscurrentlywidelyusedandhasimprovedalotcomparedtoitspredecessorLog4jinallaspects.However,ifyouwanttomakegooduseofit,youstillneedtogothroughacertainamountoflearning,especiallytounderstanditsvariousconfigurations.Let’sstarttoday’sprogress.leveljourney. 1.Introducedependencies WecanusethefollowingdependenciestointroducetheLog4j2frameworkintoourproject <!–ThelogfacadethatcomeswithLog4j2–> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.13.3</version> </dependency> <!–Log4j2specificlogimplementation–> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.13.3</version> </dependency> Ofcourse,asmentionedinthelastissue,Irecommenddirectlyusingthefollowinglog4j-slf4j-implpackage <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>2.13.3</version> </dependency> ThispackagecontainstheimplementationofLog4j2andcanalsointerfacewithSLF4J,makingitmoresuitableforapplicationinprojects. 2.Configurationfileexample Let’slookatthefollowingconfigurationfile:log4j2.xml <?xmlversion=”1.0″encoding=”UTF-8″?> <Configurationstatus=”DEBUG”monitorInterval=”30″> <!–Outputformat–> <PatternLayoutpattern=”%d{yyyy-MM-ddHH:mm:ss.SSS}-[%t]%-5level%logger{36}-%msg%n”/> <Appenders> <!–Consoleoutput–> <Consolename=”Console”target=”SYSTEM_OUT”> <!–Filter–> <ThresholdFilterlevel=”INFO”onMatch=”ACCEPT”onMismatch=”DENY”/> <!–BufferbufferSize,thedefaultvalueis256,canbeadjustedtobetween1-256–> <Bufferedmode=”ONCE”bufferSize=”256″/> </Console> <!–Fileoutput–> <RollingFilename=”RollingFile”fileName=”/path/to/logs/test.log”filePattern=”/path/to/logs/$${date:yyyy-MM}/test-%d{yyyy-MM-dd}-%i.log”> <ThresholdFilterlevel=”INFO”onMatch=”ACCEPT”onMismatch=”DENY”/> <!–Outputformat–> <PatternLayoutpattern=”%d{yyyy-MM-ddHH:mm:ss.SSS}[%t]%-5level%logger{36}-%msg%n”/> <!–Triggerstrategy–> <Policies> <!–Scrollbytime–> <TimeBasedTriggeringPolicy/> <!–Scrollbyfilesize,set10MBhere–> <SizeBasedTriggeringPolicysize=”10MB”/> </Policies> <!–Rollingstrategy–> <DefaultRolloverStrategymax=”10″/> </RollingFile> </Appenders> <Loggers> <!–Defaultlog–> <Rootlevel=”INFO”> […]

springboot log management log4j2

1. Introduction to log4j2 Apache Log4j2 is an upgrade to Log4j that provides significant improvements over its predecessor Log4j 1.x and provides many of the improvements available in Logback while fixing some issues in the Logback architecture. It is known as the best Java logging framework at present. 2. How to introduce log4j2 into the […]

Exceptions and log4j2 usage

Exception 1. Concept An abnormal event that occurs during the running of the program and the event can be handled will interrupt the running program. 2. Classification Error: represents a system-level error (a serious problem) Once a problem occurs in the system, Sun will encapsulate these errors into Error objects. Exception: represents possible problems that […]