### global config ###
# log level: DEBUG<INFO<WARN<ERROR<FATAL
log4j.rootLogger=INFO, console, file
### appender of console ###
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p %5r %c] -> %m%n
### appender of file ###
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=c:\exam.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%-5p %5r %d{yyyy-MM-dd HH:mm:ss.SSS} %c] -> %m%n
===========================================================
以下为用法:
private static Log log = LogFactory.getLog(LoginAction.class);
log.debug("test debug info");
log.info("test info info");
log.warn("test warn info");
log.error("test error info");
log.fatal("test fatal info");
五个级别依次递增