Log4J use for different files

Log4J use for different files

if u want create a new log file for action e.g click108action

step 1 create log4j appender
#Click108Appender
log4j.appender.click108=biz.minaret.log4j.DatedFileAppender
log4j.appender.click108.layout=org.apache.log4j.PatternLayout
log4j.appender.click108.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n
log4j.appender.click108.encoding=UTF-8
log4j.appender.click108.Directory=c:\\temp
log4j.appender.click108.Prefix=click108.
log4j.appender.click108.Suffix=.log
log4j.appender.click108.Append=true
log4j.appender.click108.BufferedIO=false
log4j.appender.click108.BufferSize=8192

step 2 append logger name
log4j.logger.click108=info,click108

step 3 getlogger
private static Logger log = Logger.getLogger("click108");

while call the log.info() that will create a new log file named click108+datetime in c:\temp

你可能感兴趣的:(log4j)