简体   繁体   中英

How to disable Hibernate 4.0 logging?

Every time I launch my Java on Eclipse, it floods the console with logging information:

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]

So far, I've tried (based on answer here How do you configure logging in Hibernate 4 to use SLF4J and "official" docs ):

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.

Turning off hibernate logging console output has been of no use, since as noted in the comments Hibernate 4+ uses JBOSS logging.

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
so if you use log4j , you can added log4j jar to classpath,and using log4j config to control log output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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