Log4j2 + Maven的配置文件示例详解及Logger初始化
log4j 在maven配置
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
低版本的初始化也升级了:
import org.apache.log4j.Logger;
/**
* 日志,可用于子类
*/
protected Logger log = Logger.getLogger(xxxxxxImpl.class);
改为以下:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* 日志,可用于子类
*/
protected Logger log = LogManager.getLogger(xxxxxImpl.class);