##define an appender named console
log4j.appender.console=org.apache.log4j.ConsoleAppender
#The Target value is System.out or System.err
log4j.appender.console.Target=System.out
#set the layout type of the apperder
log4j.appender.console.layout=org.apache.log4j.PatternLayout
#set the layout format pattern
log4j.appender.console.layout.ConversionPattern=[log4j-demo] %-5d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c:%l - %m%n
##define an appender named file
log4j.appender.file=org.apache.log4j.FileAppender
#define the file path and name
log4j.appender.file.File=c:/logger/logfile.txt
#set the layout type of the apperder
log4j.appender.file.layout=org.apache.log4j.PatternLayout
#set the layout format pattern
log4j.appender.file.layout.ConversionPattern=[log4j-demo] %-5d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c:%l - %m%n
##define an appender named rollfile
log4j.appender.rollfile=org.apache.log4j.RollingFileAppender
#define the file path and name
log4j.appender.rollfile.File=c:/logger/logRollFile.txt
#set the log's size
log4j.appender.rollfile.MaxFileSize=10KB
#set the layout type of the apperder
log4j.appender.rollfile.layout=org.apache.log4j.PatternLayout
#set the layout format pattern
log4j.appender.rollfile.layout.ConversionPattern=[log4j-demo] %-5d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c:%l - %m%n
##define a logger
#log4j.logger.全限定性类名或接口名=INFO,console,file,rollfile
log4j.rootLogger=INFO,console,file,rollfile
|