1、工程log4j 配置
### set log levels ### log4j.rootLogger = debug,stdout,R ### 输出到控制台 ### log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.Threshold = INFO log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} %p [%t] %c{2} (%M:%L) - %m%n ### 输出etl-web日志到文件 ### log4j.appender.R = org.apache.log4j.DailyRollingFileAppender log4j.appender.R.ImmediateFlush=true log4j.appender.R.Append = true log4j.appender.R.File =logs/lucene.log log4j.appender.R.encoding=UTF-8 log4j.appender.R.Threshold = INFO log4j.appender.R.DatePattern='.'yyyy-MM-dd log4j.appender.R.layout = org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} %p [%t] %c{2} (%M:%L) - %m%n
pom.xml添加依赖:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.2</version> </dependency>
代码中填写
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public static final Logger LOG= LoggerFactory.getLogger(QueryIndexInfoByLuceneFileDir.class);
本文来自博客园,作者:life_start,转载请注明原文链接:https://www.cnblogs.com/yangh2016/p/5888139.html