log4j.properties设置如下:
log4j.rootLogger = TRACE,stdout,file
public void configConstant(Constants me)也加入下面配置:
me.setToSlf4jLogFactory();
pom.xml也加入如下依赖
<!-- log4j 日志 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!--门面-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!--桥接器:告诉slf4j使用slf4j-simple-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
4. 具体类中加入
private static final Log log = Log.getLog(xxx.class);
log.debug("debug info");
跟进去发现isDebugEnabled始终是false
看看这个文章中用的桥接:
https://blog.csdn.net/jpf254/article/details/80757041