Disable Hibernate Logging

I am using Hibernate for a small demo project. I use Eclipse and I run the program from Eclipse, which outputs the program output to the Eclipse console.

This is a simple Java project, without Maven, no Spring, nothing. I just added the necessary hibernation libraries to my build path, which also includes jboss -logging-3.1.0.GA (which includes some of the log4j classes, so I assume log4j works here).

There are many people asking this question on the Internet, but none of the suggested solutions work for me.

I created the log4j.properties file inside the src directory of my project (so it will definitely be on the class path). The log4j.properties file is copied to the Eclipse bin directory when the project is built. It contains one line:

log4j.logger.net.sf.hibernate=fatal 

which I found on the Internet. I also tried using

 log4j.logger.org.hibernate=fatal 

which doesn't help either.

However, I get the following console output, which is all informational messages (which should not appear since I set the severity to fatal ...):

 21.11.2012 19:53:51 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 21.11.2012 19:53:51 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.1.8.Final} 21.11.2012 19:53:51 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 21.11.2012 19:53:51 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 21.11.2012 19:53:51 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!) 21.11.2012 19:53:51 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 21.11.2012 19:53:51 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: true 21.11.2012 19:53:51 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/quellsystem] 21.11.2012 19:53:51 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, password=****, autocommit=true, release_mode=auto} 21.11.2012 19:53:52 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 21.11.2012 19:53:52 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory 21.11.2012 19:53:52 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory 

I also tried adding -Dlog4j.configuration = log4j.properties VM arguments to my Eclipse startup configuration. Doesn't help anyway ...

+6
source share
2 answers

Mark this answer. It shows how to programmatically disable log4j.

fooobar.com/questions/82103 / ...

+2
source

You can use the log4j configuration file.

To use the log4j.properties file, add it to your pom.xml

 <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> </dependency> 

To disable logging, you can put it in your src/test/resources/log4j.properties file

 log4j.rootLogger=OFF 
+2
source

All Articles