我尝试将Hibernate的SQL输出记录到特定的日志文件中供以后使用,但Hibernate SQL输出也出现在我的Eclipse控制台中(我想以后会出现在Tomcat catalina.out中),并刷新我的屏幕。
有没有办法在我的控制台上避免Hibernate Log?下面是我的log4j属性和休眠设置:
loghome=PATH_TO_LOG_DIRECTORY
log4j.rootLogger=ERROR,stdout,HB
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[IRIS-${project}][%p] [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.logger.net.myapplication=info,warn,error
log4j.logger.debug=debug
log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender
log4j.appender.debug.layout=org.apache.log4j.PatternLayout
log4j.appender.debug.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.appender.debug.datePattern='.'yyyy-MM-dd
log4j.appender.debug.Threshold=DEBUG
log4j.appender.debug.append=true
log4j.appender.debug.Encoding=UTF-8
log4j.appender.debug.File=${loghome}/debug.log
log4j.logger.info=info
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
log4j.appender.info.layout=org.apache.log4j.PatternLayout
log4j.appender.info.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.appender.info.datePattern='.'yyyy-MM-dd
log4j.appender.info.Threshold=INFO
log4j.appender.info.append=true
log4j.appender.info.Encoding=UTF-8
log4j.appender.info.File=${loghome}/info.log
log4j.logger.warn=warn
log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender
log4j.appender.warn.layout=org.apache.log4j.PatternLayout
log4j.appender.warn.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.appender.warn.datePattern='.'yyyy-MM-dd
log4j.appender.warn.Threshold=WARN
log4j.appender.warn.append=true
log4j.appender.warn.Encoding=UTF-8
log4j.appender.warn.File=${loghome}/warn.log
log4j.logger.error=error
log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
log4j.appender.error.layout=org.apache.log4j.PatternLayout
log4j.appender.error.layout.ConversionPattern=[%p] [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.appender.error.datePattern='.'yyyy-MM-dd
log4j.appender.error.Threshold=ERROR
log4j.appender.error.append=true
log4j.appender.error.Encoding=UTF-8
log4j.appender.error.File=${loghome}/error.log
log4j.appender.HB=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HB.layout=org.apache.log4j.PatternLayout
log4j.appender.HB.layout.ConversionPattern=HB: [%d{yyyy-MM-dd HH:mm:ss}] [ Class = %C | Method = %M | Line = %L ] | %m |%n
log4j.appender.HB.datePattern='.'yyyy-MM-dd
log4j.appender.HB.append=true
log4j.appender.HB.Encoding=UTF-8
log4j.appender.HB.File=${loghome}/hb.log
log4j.logger.org.hibernate.SQL=HB
休眠设置:
hibernate.dialect=org.hydra.webapp.util.MySQL5MyISAMDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=<URL>
hibernate.connection.username=<USER>
hibernate.connection.password=<PASSWORD>
hibernate.connection.show_sql=false
dao.type=hibernate