简体   繁体   English

如何禁用Hibernate4.0日志?

[英]How to disable Hibernate 4.0 logging?

Every time I launch my Java on Eclipse, it floods the console with logging information: 每次我在Eclipse上启动Java时,它都会向控制台发送日志记录信息:

Jun 10, 2014 2:34:01 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Jun 10, 2014 2:34:01 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.0.Final}
Jun 10, 2014 2:34:01 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Jun 10, 2014 2:34:01 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jun 10, 2014 2:34:01 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Jun 10, 2014 2:34:01 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
Jun 10, 2014 2:34:01 AM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

[another similar ~60 lines follow] [另一个类似的~60行跟随]

So far, I've tried (based on answer here How do you configure logging in Hibernate 4 to use SLF4J and "official" docs ): 到目前为止,我已经尝试过(基于这里的答案如何配置Hibernate 4中的日志记录以使用SLF4J和“官方” 文档 ):

System.setProperty("org.jboss.logging.provider", "jdk");
java.util.logging.Logger.getLogger("org.hibernate").setLevel(Level.OFF);

But it makes no difference. 但它没有任何区别。 Hibernate keeps spamming the console. Hibernate不断向控制台发送垃圾邮件。

Turning off hibernate logging console output has been of no use, since as noted in the comments Hibernate 4+ uses JBOSS logging. 关闭hibernate日志记录控制台输出是没有用的,因为正如评论中所述,Hibernate 4+使用JBOSS日志记录。

To use JBoss Logging with Log4j, the log4j jar would also need to be available on the classpath.

To use JBoss Logging with Log4j2, the log4j2 jar would also need to be available on the classpath.

To use JBoss Logging with Slf4j, the slf4j-api jar would also need to be available on the classpath plus any needed slf4j backend.

The above quote from http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html 以上引自http://docs.jboss.org/hibernate/orm/4.3/topical/html/logging/Logging.html
so if you use log4j , you can added log4j jar to classpath,and using log4j config to control log output. 所以如果你使用log4j,你可以将log4j jar添加到classpath,并使用log4j config来控制日志输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM