当前位置:网站首页>Log4j use
Log4j use
2022-06-11 03:20:00 【Maple Leaf sprite s】
Configuration and use log4j
(1)mybatis Core profile import dependency
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
(2) To configure log4j.properties
### Set up ###
# Rank as debug Log file output to console console、stdout file file
log4j.rootLogger = DEBUG,stdout,file
### Output information to console ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.Threshold = DEBUG
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
# File output related settings
log4j.appender.file = org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File = ./log/lin.log
log4j.appender.file.Append = true
log4j.appender.file.MaxFileSize = 10mb
log4j.appender.file.Threshold = DEBUG
log4j.appender.file.layout = org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
# Log output level
log4j.logger.org.mybatis=DEBUG
log4j.logger.java.sql=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
(3)mapper To configure log4j For the implementation of log
<settings>
<setting name="logImpl" value="LOG4J"/>
</settings>
(4) Use
Easy to use
1. In use log4j Import package in class
import org.apache.log4j.Logger;
2. Log object , The parameter is of the current class class
static Logger logger=Logger.getLogger(UserMapperTest.class);
3. The level of logging
@Test
public void testLog4j(){
logger.debug("debug: Into the testLog4j");
logger.error("error: Into the testLog4j");
logger.info("info: Into the testLog4j");
}
边栏推荐
- PIP installation Qt5.
- cv. Matchtemplate image model matching opencv
- Cypress 88359 WL command enable hotspot
- C语言数组的简单认识
- com. mchange. v2.c3p0. Combopooleddatasource red
- C language array and pointer exercises
- CPT 102_ LEC 18
- Fuluo classic source code Fuluo classic system development principle sharing
- HQChart实战教程55-欧易网K线面积图
- pip 安装 qt5 。
猜你喜欢

ASLR
![[safety science popularization] mining technology starts from the love story of a man of science and Engineering](/img/01/73376c133c33527e479685f8680238.jpg)
[safety science popularization] mining technology starts from the love story of a man of science and Engineering

Detailed explanation of unity project optimization (continuous supplement)
![[new open source project] dynamic configuration task scheduling framework gobrs async joins the dromara open source community](/img/26/2d0c4e8f7f4055e614080fe526328c.png)
[new open source project] dynamic configuration task scheduling framework gobrs async joins the dromara open source community

Help you distinguish GNU, GCC, GCC and G++

Dépannage du problème de retard des données de communication du micro - ordinateur à puce unique

How should Xiaobai start the Amazon self support evaluation?

Solr initialization failure: requesthandler INIT failure

亚马逊测评自养号,小白应该如何开始?

Demand and Prospect of 3D GIS Industry
随机推荐
计算机视觉(AI)面试大全
window10安装keras
B / Qurt Utilisateur Guide (19)
怎样确保消息的可靠性投递?
关于玩家身上有个普通Set并发安全的讨论
Basic use of sonarqube platform
删除CSDN上传图片的水印
单片机通信数据延迟问题排查
Hough transform of image
Hqchart actual combat tutorial 55 area map of K line of ouyi.com
Disk quota exceeded
org. apache. solr. common. SolrException:Could not load core configuration for core hotel
cv. Matchtemplate image model matching opencv
Delete the watermark of the picture uploaded by CSDN
postgresql源码学习(22)—— 故障恢复③-事务日志的注册
pip 安装 qt5 。
File file = new file ("test.txt") file path
GD32 can发送报no mailbox 故障
C语言指针
File file = new File(“test.txt“)文件路径