25 读取jar包内log4j.properties文件方法

   //读取log4j日志配置文件
        InputStream inputStream=ApplicationExecutor.class.getResourceAsStream("/log4j_hwf.properties");
        PropertyConfigurator.configure(inputStream);

 

 ### set log levels ###
log4j.rootLogger = 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


### 输出日志到文件 按照日志文件大小 ###
log4j.appender.R = org.apache.log4j.RollingFileAppender 
log4j.appender.R.ImmediateFlush=true
log4j.appender.R.Append = true
log4j.appender.R.File = logs/hwf_runtime.log
log4j.appender.R.MaxFileSize= 100MB
log4j.appender.R.MaxBackupIndex= 50
log4j.appender.R.encoding= UTF-8
log4j.appender.R.Threshold = INFO
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

 

posted @ 2016-12-12 11:00  life_start  阅读(2166)  评论(0编辑  收藏  举报