java代码
this.logger = Logger.getLogger(Folder.class);
this.rcMarryGaofaLogger = Logger.getLogger("aoa");
//指定日志配置文件,这样在wrapper环境下可以单独配置日志
PropertyConfigurator.configure("log4j.properties");
log4j.properties
log4j.rootLogger= info, stdout, D
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern= %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
log4j.appender.stdout.layout.ConversionPattern= %d %p %t [%C.%M(%L)] - <%m>%n
#每天生成一个文件
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = C:/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = info
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.MaxFileSize=50MB
log4j.appender.D.MaxBackupIndex=3
log4j.appender.D.layout.ConversionPattern = %d %p %t [%C.%M(%L)] - <%m>%n
# data log
log4j.logger.aoa= info, stdout, aoadata
#每天生成一个文件
log4j.appender.aoadata = org.apache.log4j.DailyRollingFileAppender
log4j.appender.aoadata.File = C:/data_log.log
log4j.appender.aoadata.Append = true
log4j.appender.aoadata.Threshold = info
log4j.appender.aoadata.layout = org.apache.log4j.PatternLayout
log4j.appender.aoadata.layout.ConversionPattern = %d %p %t [%C.%M(%L)] - <%m>%n
log4j.appender.aoadata.MaxFileSize=50MB
log4j.appender.aoadata.MaxBackupIndex=3
#指定一个类的日志级别
log4j.logger.com.framework.servlet=DEBUG
来源:https://www.cnblogs.com/javaeye235/p/4223407.html