Darwly
Darwly

Reputation: 344

Stop Hibernate console output, without log4j

As said in the title i want to stop Hibernate console output, without using log4j. I have tried to use log4j but i havent got anywhere. What i want is the console INFO outputs to stop. And if i am using log4j is it possible to do it without .properties or .xml files, just set the settings in the source. tnx

Upvotes: 2

Views: 6772

Answers (3)

Pascal Thivent
Pascal Thivent

Reputation: 570615

I can certify that Hibernate won't log on the console unless your configuration somehow allows it to do so. So, what version of Hibernate are you using? What SLF4J binding are you using if you're not using LOG4J as logging backend? Do you have a configuration file for it?

Or maybe did you turn on the echoing of SQL to stdout in your hibernate.cfg.xml?:

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

You need to help readers a bit, we don't all have crystal balls :) Please provide more material.


Update: It appears that the OP had the slf4-simple binding on his class path which is precisely used to output INFO log messages to the console:

Binding for Simple implementation, which outputs all events to System.err. Only messages of level INFO and higher are printed. This binding may be useful in the context of small applications.

Replacing slf4-simple with another binding (you should not have multiple bindings on the class path) with the appropriate configuration should silence Hibernate.

Upvotes: 3

YoK
YoK

Reputation: 14505

Solution looks like adding slf4j-log4j12-1.5.2.jar in your classpath if you are using slf4j-api. This is other than configuration added for log4j for disabling logs.

This link should be useful.

http://ayushsuman.blogspot.com/2010/07/turning-off-hibernate-logging-console.html

You can also check other solutions from :

Can't stop Hibernate from writing log to console (log4j.properties is ok)

Upvotes: 2

npinti
npinti

Reputation: 52205

You can try this:

Logger log = Logger.getLogger("org.hibernate");
        log.setLevel(Level.WARNING);

It should work. Just call it before you open any sessions.

Upvotes: 3

Related Questions