Reputation:
I am using Hibernate for a small demo project. I am using Eclipse and I start the program from within Eclipse, which will print program output to the Eclipse console.
It's a plain Java project, no Maven, no Spring, no nothing. I just added the required hibernate libraries to my build path, which also includes jboss-logging-3.1.0.GA (which includes some log4j classes, so I suppose log4j is at work here).
There are many people asking this question on the web, but none of the proposed solutions work for me.
I created a log4j.properties file inside the src directory of my project (so it definately will be on the classpath). The log4j.properties file is copied to the bin directory by Eclipse when the project is being build. It contains one single line:
log4j.logger.net.sf.hibernate=fatal
which I found on the web. I also tried with
log4j.logger.org.hibernate=fatal
which does not help either.
Still I get following console output, which are all info messages (which should not appear as 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 to the VM arguments of my Eclipse run configuration. Doesn't help either way ...
Upvotes: 8
Views: 20006
Reputation: 51
Yes just adding this dependencies to your pom.xml will disactivate logging of INFO and WARN from Hibernate also wthout any log properties / or log4j2.xml file
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
Upvotes: 0
Reputation: 19
You can use log4j configuration file.
To be able to use log4j.properties
file add this to your pom.xml
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
To disable logging, you can put this in your src/test/resources/log4j.properties
file
log4j.rootLogger=OFF
Upvotes: 1