log4j 入门

来源:互联网 发布:山灵m2知乎 编辑:程序博客网 时间:2024/04/28 06:49
入门:

log4j download path : http://mirror.bit.edu.cn/apache/logging/log4j/1.2.16/apache-log4j-1.2.16.zip

 

a helloworld exmple: 

 

import org.apache.log4j.BasicConfigurator;import org.apache.log4j.Level;import org.apache.log4j.Logger;    public class TestLog4J {      public static void main(String[] args) {      // create a log for TestLog4J class        Logger logger = Logger.getLogger(TestLog4J.class);         // use the default config       BasicConfigurator.configure();       // set this log level ,it will hide if it's output level lower this level         logger.setLevel(Level.ALL);                logger.debug("this is debug");        logger.info("this is info");        logger.error("this is a error");        logger.fatal("this is a fatal error");    }    } 


 

延伸阅读:

              http://www.hudong.com/wiki/log4j
              http://www.cnblogs.com/flurry/archive/2010/02/25/1673549.html


原创粉丝点击