log4j.properties(放在src根目录下面)
# Set root category priority to info and its only appender to #console.
log4j.rootCategory=info,console,R
#log4j.debug=true
# console is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=info
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p]->] %m%n
# R is set to be a File appender using a PatternLayout.
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.Append=true
log4j.appender.R.Threshold=info
log4j.appender.R.MaxFileSize=1024KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.File=D\:/log/logFile.log
#log4j.appender.R.File=./log/logFile.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%r]-[%c]-[%p] %m%n
需要一个jar包:org.apache.log4j_1.2.15.v201005080500.jar
# Set root category priority to info and its only appender to #console.
log4j.rootCategory=info,console,R
#log4j.debug=true
# console is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=info
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p]->] %m%n
# R is set to be a File appender using a PatternLayout.
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.Append=true
log4j.appender.R.Threshold=info
log4j.appender.R.MaxFileSize=1024KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.File=D\:/log/logFile.log
#log4j.appender.R.File=./log/logFile.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%r]-[%c]-[%p] %m%n
需要一个jar包:org.apache.log4j_1.2.15.v201005080500.jar