常用的配置如下

log4j.rootLogger=WARN,console
#log4j.rootLogger=DEBUG, stdout
# console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.encoding=UTF-8
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] -%-4r %d %m %x %n

注意:文中添加了编码格式,避免在Linux系统中,出现乱码