大家对日志,应该很熟悉,一般我们都是用log4j,当然log4j也是有优先级别的
这里用一个简单的实例来说明下
下载log4j的jar包,编写一个测试类,如下图
package com.asiainfo.log;
import org.apache.log4j.Logger;
public class UserLog {
public static final Logger logger = Logger.getLogger(UserLog.class);
public void add(){
logger.debug("hello wolrd debug");
logger.info("hello wolrd info");
logger.warn("hello wolrd warn");
logger.error("hello wolrd error");
logger.fatal("hello wolrd fatal");
}
}
配置log4j.properties文件
# Global logging configuration\uff0c\u5efa\u8bae\u5f00\u53d1\u73af\u5883\u4e2d\u8981\u7528debug
log4j.rootLogger=DEBUG,stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [