Turning off hibernate logging console output
Try to set more reasonable logging level. Setting logging level to info
means that only log event at info
or higher level (warn
, error
and fatal
) are logged, that is debug
logging events are ignored.
log4j.logger.org.hibernate=info
or in XML version of log4j config file:
<logger name="org.hibernate">
<level value="info"/>
</logger>
See also log4j manual.
Turn off hibernate logging to console
I'm fairly certain that you're seeing those SQL statements because somewhere in your Hibernate config the property "hibernate.show_sql" is set to true. Find that setting and change to false.
turn off hibernate logging in eclipse
If you just want to turn off Hibernate SQL logging in Spring's Petclinic sample application, set jpa.showSql
to false in src/main/resources/spring/data-access.properties.
Hope this helps.
How can we disable the hibernate logs?
This worked for me..
static {
// Initialized log4j2 Property and disable hibernate log
Configurator.initialize("LOGS", "Projects/log4j.properties");
Configurator.setLevel("org.hibernate", org.apache.logging.log4j.Level.OFF);
}
Disabling Hibernate log messages in a Spring application
If you're using it, you might need to set <property name="show_sql">false</property>
in your hibernate configuration file.
How to disable Hibernate sql output
The only way I managed to get this to stop spitting out SQL was to add the property at a code level.
private Properties additionalProperties(){
var properties = new Properties();
properties.setProperty("hibernate.show_sql", "false");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
return properties;
}
The portion containing the dialect was already there and I added the show_sql - I am not sure why the properties file was not doing this, perhaps
em.setJpaProperties(additionalProperties());
is overriding the properties set in the application properties file (which makes sense as it is a "set" call). Upon attempting to move the these values to the properties file and stop setting them in the config file the properties still weren't being set.
I am leaving this here as an explanation for anyone else that might have gone down the same rabbit hole as myself - should I make further progress on setting the values in the properties file I will share it here as well.
Thanks to everyone that reviewed this questions and those that tried to help
Related Topics
Getresourceasstream() Is Always Returning Null
Configuring Log4J Loggers Programmatically
Add Custom CSS to HTML Code with Jsoup
Pausing/Stopping and Starting/Resuming Java Timertask Continuously
Android: Email Client Receiver Email Id Empty in Android-Parse
Android: How to Disable List Items on List Creation
How to Hide a View Programmatically
Error Inflating Class Com.Google.Ads.Adview
How to Close a Java Swing Application from the Code
How to Limit the Number of Characters in Jtextfield
How to Clear the (Css) Visited History of an Android Webview
Android Import Java.Nio.File.Files; Cannot Be Resolved
Android Firestore Convert Array of Document References to List<Pojo>