gpt4 book ai didi

eclipse - 如何防止 hibernate 日志到我的控制台(eclipse 和 tomcat 通用日志)?

转载 作者:行者123 更新时间:2023-11-28 23:00:05 25 4
gpt4 key购买 nike

我试图将 Hibernate 的 SQL 输出记录到一个特定的日志文件中供以后使用,但是 Hibernate SQL 输出也出现在我的 Eclipse 控制台中(我想稍后会出现在 Tomcat catalina.out 中),并刷新了我的屏幕.

是否有任何方法可以避免在我的控制台上出现 Hibernate Log?下面是我的 log4j 属性和 hibernate 设置:


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 设置:

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

最佳答案

似乎您必须将可加性标志设置为 false 以防止将日志记录事件发送到父级(在本例中为控制台记录器)。检查

Log4j Manualthis

关于eclipse - 如何防止 hibernate 日志到我的控制台(eclipse 和 tomcat 通用日志)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20538490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com