log4j.rootLogger=warn, A1,warnlog
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
public class Bar {
static Logger logger = Logger.getLogger(Bar.class);
public void doIt() {
logger.debug("there is a debug...");
logger.info("there is a info...");
logger.warn("there is a warning...");
}
}
2.关于“log4j:WARN Please initialize the log4j system properly”:
你的tomcat/common/lib下是不是有个log4j的jar啊?删了试试!应该没问题。
原文出自:http://www.blogjava.net/flysky19/articles/98130.html