控制台打印信息
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
在 pom 中添加
<!-- log -->
<!-- https://mvnrepository.com/artifact/log4j/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>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
<!-- <scope>test</scope> -->
</dependency>
新建 log4j.properties 内容简单如下
#ERROR、WARN、INFO、DEBUG
log4j.rootLogger=debug,stdout
LEVEL=DEBUG
log4j.logger.com.ibatis=${LEVEL}
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=${LEVEL}
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=${LEVEL}
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=${LEVEL}
log4j.logger.java.sql.Connection=${LEVEL}
log4j.logger.java.sql.Statement=${LEVEL}
#log4j.logger.java.sql.PreparedStatement=${LEVEL}
log4j.logger.java.sql.ResultSet=${LEVEL}
#log4j.logger.redis.clients.jedis=${LEVEL}
log4j.logger.org.springframework=ERROR
log4j.logger.org.compass=${LEVEL}
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
另外对于 log4j1.x ,http://logging.apache.org/log4j/1.2/faq.html#noconfig 写到
On August 5, 2015 the Logging Services Project Management Committee announced that Log4j 1.x had reached end of life. For complete text of the announcement please see the Apache Blog. Users of Log4j 1 are recommended to upgrade to Apache Log4j 2.
大概意思是:2015年8月5日 项目管理委员会宣布 log4j 1.x 已经走到生命尽头,有关公告的完整内容,请参阅Apache博客。建议log4j 1的用户升级到apache log4j 2。