码迷,mamicode.com
首页 > 其他好文 > 详细

slf4j+log4j配置(Maven)

时间:2016-05-23 21:15:46      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:

  • 首先配置Maven依赖
技术分享
<!-- http://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.21</version>
</dependency>
View Code
  • 代码目录添加log4j.properties配置文件
技术分享
#config root logger
log4j.rootLogger = INFO,system.out
log4j.appender.system.out=org.apache.log4j.ConsoleAppender
log4j.appender.system.out.layout=org.apache.log4j.PatternLayout
log4j.appender.system.out.layout.ConversionPattern=LuceneServer Logger-->%5p{%F:%L}-%m%n

#config this Project.file logger
log4j.logger.thisProject.file=INFO,thisProject.file.out
log4j.appender.thisProject.file.out=org.apache.log4j.DailyRollingFileAppender
log4j.appender.thisProject.file.out.File=logContentFile.log
log4j.appender.thisProject.file.out.layout=org.apache.log4j.PatternLayout
View Code
  • 代码引入
private static final Logger logger = LoggerFactory.getLogger(SeachTest.class);

 

slf4j+log4j配置(Maven)

标签:

原文地址:http://www.cnblogs.com/naiyou/p/5521281.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!