log4j hibernate和spring的debug信息能够写入日志文件,但是代码中打的log.debug(),在控制台上可以输出,但是不能写入日志文件。
log4j配置如下:
设置
log4j.rootLogger = DEBUG,stdout,D
输出信息到控制抬
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.Threshold = INFO
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
输出DEBUG 级别以上的日志到
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = ${xxxx.root}/$sys_data/log/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern =%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
#log4j for springMVC
#log4j.logger.org.springframework=WARN
#hibernate
#log4j.logger.org.hibernate.SQL=ERROR
#log4j.logger.org.hibernate=ERROR