log4j.properties配置

配置:

#全局日志配置 
log4j.rootLogger=DEBUG,Console,RollingFile
#######################  日志输出策略      ##########################
#包下某个类的日志
#log4j.logger.com.project.dao.UserinfoDao=TRACE
#包下某个类对应方法的日志
#log4j.logger.com.project.filter.SessionFilter.judgeLogin=INFO
log4j.category.com.mybatis=DEBUG
log4j.category.org.springframework=ERROR

#Console 控制台日志输出
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
#SingleFile 单一日志文件
log4j.appender.SingleFile=org.apache.log4j.FileAppender
log4j.appender.SingleFile.File=./SingleFile.log
log4j.appender.SingleFile.layout=org.apache.log4j.PatternLayout
log4j.appender.SingleFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
#RollingFile 固定大小日志文件
log4j.appender.RollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.appender.RollingFile.MaxFileSize=2048KB
log4j.appender.RollingFile.MaxBackupIndex=1000
log4j.appender.RollingFile.File=./RollingFile.log
#DailyRollingFile  每天一个日志文件
log4j.appender.DailyRollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DailyRollingFile.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.DailyRollingFile.file=./Daily.log
log4j.appender.DailyRollingFile.Append=true
log4j.appender.DailyRollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DailyRollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n

你可能感兴趣的:(log4j)