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
3 Answers
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.

- 51,780
- 5
- 72
- 96
-
1He nice, this part helped me a lot to.. tnx . Well i used it to change the level in the source with out depending on the properites files. – Darwly Aug 28 '10 at 08:31
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 toSystem.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.

- 562,542
- 136
- 1,062
- 1,124
-
already solver, my comment explains it all. It was my dummy mestake, hibernate does not output if not sad u re right, and the problem was in my bindings, multiple bindings not a good idea, slf4-simple and log4j. but all is solved now. my upper comment shows my solution. And ill remember to give more info in future. Tnx – Darwly Aug 28 '10 at 08:27
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)
-
thx, this helps a lot, but this example generates multiple binding warnings of the loggers, but i am getting close to a solution. Tnx ull get a check >D – Darwly Aug 28 '10 at 07:51
-
so, the first link is not a solution, it just creates not configured ground. So, if u re using log4j binding, dont use slf4.simple. The solution is getting all the right versions. my solution was. Hibernate 3.5 slf4j-api-1.6.1 slf4j-log4j12-1.6.1 log4j-1.2.16 and setting the properties with the PropertyConfigurator from log4j, to FATAL – Darwly Aug 28 '10 at 08:16
-
1@Martes I'm sorry but the blog post mentioned here is plain wrong (I left a comment to explain the problem but the author decided to ignore his mistake and deleted my comment). The author solved his problem "by accident" by putting several bindings on the classpath, hiding the `slf4j-simple` binding. But this is wrong and SLF4J will indeed complain about that. So no offense but this reference is just horribly wrong and this accepted answer is also incorrect. The solution is not to add random SLF4J bindings, the solution is to replace the `slf4j-simple` binding. – Pascal Thivent Aug 30 '10 at 00:25
-
This is not an answer. I came here with the same problem and got no where with this response. – Jan 07 '14 at 14:08
-
@ThreaT This is an answer. It may not be a **good answer**, but it is an answer. If you don't think this is a good answer, please downvote it. That's what downvotes are for. – David Wasser Jan 08 '14 at 11:58
-
@DavidWasser: I did downvote it long before your comment. This is not an answer, it would be helpful as a comment but by definition an answer must resolve a question otherwise it's either incorrect or irrelevant (for another question perhaps). – Jan 08 '14 at 12:40