log4j

#配置rootLogger  (级别+输出源)
log4j.rootLogger=debug,A6

#to Console
log4j.appender.A=org.apache.log4j.ConsoleAppender
log4j.appender.A.layout=org.apache.log4j.SimpleLayout

#to Console
log4j.appender.A5=org.apache.log4j.ConsoleAppender
log4j.appender.A5.layout=org.apache.log4j.PatternLayout
log4j.appender.A5.layout.ConversionPattern=[%t] [%p] [%d{yyyy/MM/dd HH:mm:ss:SSS}] %l %m %n

#to Console2 TTCCLayout
log4j.appender.A3=org.apache.log4j.ConsoleAppender
log4j.appender.A3.layout=org.apache.log4j.TTCCLayout


#to file1
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=wepull.log
log4j.appender.A1.layout=org.apache.log4j.SimpleLayout

#to file2 HTML
log4j.appender.A4=org.apache.log4j.FileAppender
log4j.appender.A4.File=ht.html
log4j.appender.A4.layout=org.apache.log4j.HTMLLayout

#to file3
log4j.appender.A6=org.apache.log4j.RollingFileAppender
log4j.appender.A6.File=wepull.log
log4j.appender.A6.MaxFileSize=2KB
log4j.appender.A6.MaxBackupIndex=1 
log4j.appender.A6.layout=org.apache.log4j.PatternLayout
log4j.appender.A6.layout.ConversionPattern=[%t] [%p] [%d{yyyy/MM/dd HH:mm:ss:SSS}] %l %m %n

 

package com.wepull.logj4.demo;

import org.apache.log4j.Logger;

public class Test {

	public Logger logger = Logger.getLogger(Logger.class.getName());

	private void fun() {

		logger.error(" this is error msg");
		logger.warn(" this is warn msg");
		logger.info(" this is info msg");
		logger.debug(" this is debug msg");

	}

	public static void main(String[] args) {
		Test d = new Test();
		d.fun();

	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值