首页 > 其他 > 详细

slf4j+log4j配置(Maven)

时间:2016-05-23 21:13:58      阅读:398      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!