commons.logging版本1.1.1
log4j版本1.2.15
使用NetBeans IDE开发
-----------------------------------/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package log4j.test2;/**
*
* @author Administrator
*/import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
//import org.apache.log4j.PropertyConfigurator;
public class TestLog{private static Log log = LogFactory.getLog(TestLog.class);public void test(){log.debug("111");log.info("222");log.warn("333");log.error("444");log.fatal("555");}public static void main(String[] args){PropertyConfigurator.configure(TestLog.class.getResource("log4j.properties"));//如果没有这句话,就不能自动找到log4j这个包,为什么呢?TestLog testLog = new TestLog();testLog.test();}}
==============================================
如果不加PropertyConfigurator.configure(TestLog.class.getResource("log4j.properties"));这句话,会发生错误。
错误如下:
log4j:WARN No appenders could be found for logger (log4j.test2.TestLog).
log4j:WARN Please initialize the log4j system properly.意思就是找不到log4j呗。这是怎么回事?
commons.logging不是可以自动搜索到log4j么?
而且网上说不用写commons-logging.properties。我这是什么情况啊?注:我另一个工程只用log4j.jar,不用commons-logging是可以成功实现的。
log4j版本1.2.15
使用NetBeans IDE开发
-----------------------------------/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package log4j.test2;/**
*
* @author Administrator
*/import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
//import org.apache.log4j.PropertyConfigurator;
public class TestLog{private static Log log = LogFactory.getLog(TestLog.class);public void test(){log.debug("111");log.info("222");log.warn("333");log.error("444");log.fatal("555");}public static void main(String[] args){PropertyConfigurator.configure(TestLog.class.getResource("log4j.properties"));//如果没有这句话,就不能自动找到log4j这个包,为什么呢?TestLog testLog = new TestLog();testLog.test();}}
==============================================
如果不加PropertyConfigurator.configure(TestLog.class.getResource("log4j.properties"));这句话,会发生错误。
错误如下:
log4j:WARN No appenders could be found for logger (log4j.test2.TestLog).
log4j:WARN Please initialize the log4j system properly.意思就是找不到log4j呗。这是怎么回事?
commons.logging不是可以自动搜索到log4j么?
而且网上说不用写commons-logging.properties。我这是什么情况啊?注:我另一个工程只用log4j.jar,不用commons-logging是可以成功实现的。
解决方案 »
- java.lang.NoSuchMethodError: org.apache.struts2.interceptor.StrutsConversionErro
- 选择上传图片 客户端显示问题
- JDBC小问题
- Struts 新手问题 jsp 设置两个按钮 在对应的Action初始化函数中,如何知道用户按了那个按钮?
- 关于Struts里ActionForm保存值的问题,请教大虾们
- 在写XML时,只认全角空格,不认半角空格。有什么解决办法吗?
- 求助,struts1.1里配置数据库连接池,启动时报错,不能使用!
- struts问题:html:link是否可以提交一个form。。。急。高分相赠
- 请教!!!!
- [醒灯]ArrayList如何Sort[醒灯]
- 关于数据库查询语句的疑惑,问题怎么解决?
- struts2 xml验证的一个问题
什么是类路径啊?
在哪儿设置啊?
NetBeans里面没有,我直接把它放在和这个类在一个包里了package log4j.test2。