45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:使用及配置commons-logging log4j的步骤

使用及配置commons-logging log4j的步骤

2016-08-29 08:37:28 来源:www.45fan.com 【

使用及配置commons-logging log4j的步骤

commons-logging.properties

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

log4j.properties

log4j.rootLogger=info, A1

log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=log/strutsAppLog.log
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c %x [%F:%L] - %m%n

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
*
* @author dinstone

* @date 2006/09/04
* @since JDK 1.4 Struts 1.2
* @see
*/
public class LogTest
{
private static Log log = LogFactory.getLog(LogTest.class);
public static void main(String[] args)
{
System.out.println("start");
log.debug("debug");
log.error("error");
log.fatal("fatal");
log.info("info");
log.warn("warn");
System.out.println("end");
}

}

log/strutsAppLog.log

2006-09-04 13:51:16,062 [main] ERROR test.LogTest [LogTest.java:25] - error
2006-09-04 13:51:16,062 [main] FATAL test.LogTest [LogTest.java:26] - fatal
2006-09-04 13:51:16,062 [main] INFO test.LogTest [LogTest.java:27] - info
2006-09-04 13:51:16,062 [main] WARN test.LogTest [LogTest.java:28] - warn

 

本文地址:http://www.45fan.com/a/question/69195.html
Tags: 配置 LOG4J commons-logging
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部