Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning off hibernate logging console output

I'm using hibernate 3 and want to stop it from dumping all the startup messages to the console. I tried commenting out the stdout lines in log4j.properties but no luck. I've pasted my log file below. Also I'm using eclipse with the standard project structure and have a copy of log4j.properties in both the root of the project folder and the bin folder.

### direct log messages to stdout ### #log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.Target=System.out #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n  ### direct messages to file hibernate.log ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=hibernate.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n  ### set log levels - for more verbose logging change 'info' to 'debug' ###  log4j.rootLogger=warn, stdout  #log4j.logger.org.hibernate=info log4j.logger.org.hibernate=debug  ### log HQL query parser activity #log4j.logger.org.hibernate.hql.ast.AST=debug  ### log just the SQL #log4j.logger.org.hibernate.SQL=debug  ### log JDBC bind parameters ### log4j.logger.org.hibernate.type=info #log4j.logger.org.hibernate.type=debug  ### log schema export/update ### log4j.logger.org.hibernate.tool.hbm2ddl=debug  ### log HQL parse trees #log4j.logger.org.hibernate.hql=debug  ### log cache activity ### #log4j.logger.org.hibernate.cache=debug  ### log transaction activity #log4j.logger.org.hibernate.transaction=debug  ### log JDBC resource acquisition #log4j.logger.org.hibernate.jdbc=debug  ### enable the following line if you want to track down connection ### ### leakages when using DriverManagerConnectionProvider ### #log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trac5
like image 566
Jared Avatar asked Nov 22 '08 15:11

Jared


People also ask

What is logging in hibernate?

Hibernate utilizes Simple Logging Facade for Java (SLF4J) in order to log various system events. SLF4J can direct your logging output to several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding.


1 Answers

Important notice: the property (part of hibernate configuration, NOT part of logging framework config!)

hibernate.show_sql 

controls the logging directly to STDOUT bypassing any logging framework (which you can recognize by the missing output formatting of the messages). If you use a logging framework like log4j, you should always set that property to false because it gives you no benefit at all.

That circumstance irritated me quite a long time because I never really cared about it until I tried to write some benchmark regarding Hibernate.

like image 159
user1050755 Avatar answered Sep 21 '22 15:09

user1050755