Personally combine the learning video to make a simple understanding and record. The benefits of the log facade technology: the facade technology is an interface-oriented development, no longer dependent on specific implementation classes, and reduces code coupling. You can flexibly switch the log framework according to actual needs. Unified API , which is convenient for developers to learn and use Unified configuration management facilitates the maintenance of project logs
//不导入第三方日志框架,默认使用自带的JCL日志框架记录日志 Log log = LogFactory.getLog(JCLTest01.class); log.info("info信息");
Need to import the built-in logging framework dependencies
<!--jcl依赖--> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency>
Displayed log information
The log information displayed after importing the log framework, such as log4j
First add log4j configuration
#配置根节点logger log4j.rootLogger=trace,console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.conversionPattern=[%-10p]%r %c%t%d{yyyy-MM-dd HH:mm:ss:SSS} %m%n
import dependencies
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
Displayed log information
why start
curiosity is motivation