1、maven添加
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
2、resource添加log4j.properties
#定义LOG输出级别 INFO,Console,File
log4j.rootLogger=INFO,console,dailyFile
#定义日志输出目的地为控制台
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.encoding=UTF-8
log4j.appender.console.layout=org.apache.log4j.PatternLayout
#日期:%d 线程:%t 日志级别-5p 报错类:%c 报错信息:%m%n
log4j.appender.console.layout.ConversionPattern=[%d] [%-5p] [%c] %m%n
log4j.logger.org.mybatis =DEBUG
3、使用方式
private static final Logger log = LoggerFactory.getLogger(HbaseServiceImpl.class);
log.error("错误日志记录");
标签:console,配置,slf4j,appender,Slf4j,org,日志,log4j From: https://www.cnblogs.com/robots2/p/17859366.html