首页 > 代码库 > 1、工程log4j 配置

1、工程log4j 配置

 ### set log levels ###log4j.rootLogger = debug,stdout,R### 输出到控制台 ###log4j.appender.stdout = org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target = System.outlog4j.appender.stdout.Threshold = INFOlog4j.appender.stdout.layout = org.apache.log4j.PatternLayoutlog4j.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.DailyRollingFileAppenderlog4j.appender.R.ImmediateFlush=truelog4j.appender.R.Append = truelog4j.appender.R.File =logs/lucene.loglog4j.appender.R.encoding=UTF-8log4j.appender.R.Threshold = INFOlog4j.appender.R.DatePattern=‘.‘yyyy-MM-ddlog4j.appender.R.layout = org.apache.log4j.PatternLayoutlog4j.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);

 

1、工程log4j 配置