开发者

Understanding Hibernate Logging Categories

开发者 https://www.devze.com 2023-02-12 09:59 出处:网络
I\'m having some trouble understanding the Hibernate logging categories.I\'m basing my assumptions on the documentation located at: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-c

I'm having some trouble understanding the Hibernate logging categories. I'm basing my assumptions on the documentation located at: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-logging

I'm using log4j.properties to configure the logging level for Hibernate, using the following:

log4j.logger.org.hibernate=DEBUG
log4j.additivity.org.hibernate.SQL=false

outputs info for all catego开发者_如何学Gories of hibernate (org.hibernate.loader, org.hibernate.jdbc, org.hibernate.engine, etc).

What I'm really wanting is only the org.hibernate.SQL category to log at the DEBUG level. I've tried various combinations of:

log4j.logger.org.hibernate=INFO
log4j.logger.org.hibernate.SQL=DEBUG
log4j.additivity.org.hibernate.SQL=false

But it never seems to "see" the SQL category, and only uses the org.hibernate logging level.

Is what I'm wanting to do even possible? If so, what am I getting wrong in trying to make it work?

Thanks for any suggestions!


I think you forget to specify your appender after DEBUG:-

Try this:-

log4j.logger.org.hibernate.SQL=DEBUG, CONSOLE_APPENDER  
log4j.additivity.org.hibernate.SQL=false 

log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号