I've already set
<property name="show_sql">false</property>
and I have disabled all messages in log4j.properties
But Hibernate write to console with all queries & statements.
I've already set
<property name="show_sql">false</property>
and I have disabled all messages in log4j.properties
But Hibernate write to console with all queries & statements.
Setting the hibernate.show_sql
to true
tells hibernate to Write all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL
to debug.
So even if you set this property to false
, make sure that you don't have the following category defined (or configured to use a console appender):
log4j.logger.org.hibernate.SQL=DEBUG
Also, make sure that you don't set the hibernate.show_sql
programmatically to true when instancing your Configuration
object. Hunt something like this:
Configuration cfg = new Configuration().configure().
.setProperty("hibernate.show_sql", "true");
Note that the setProperty(String propertyName, String value)
takes as first parameter the full name of a configuration property i.e. hibernate.show_sql
, not just show_sql
.
<logger name="org.hibernate.type" level="ALL" /> <logger name="org.hibernate.SQL" level="WARN" /> <logger name="org.hibernate" level="DEBUG" />
–
Edeline HI there, i figured out you can solve this also with this 2 lines in your log4j.properties file.
log4j.logger.org.hibernate = WARN
log4j.logger.org.hibernate = ERROR
You adding something like this to log4j.properties?
log4j.logger.org.hibernate = WARN
It seems very strange, but when Use Eclipse with JUnit Test task, all output still goes to Console (in Eclipse Console window).
But when I use ant command for unit testing, nothing goes to console.
As mentioned before, you need first to set hibernate.show_sql
to false
. This will prevent hibernate output to console or Tomcat stdout log.
But in order to direct your sql output to another log use this code in log4j.xml file:
<logger name="org.hibernate.SQL" additivity="false">
<level value="DEBUG" />
<appender-ref ref="hibernate"/>
</logger>
To keep the normal hibernate log level (WARN / ERROR) to console use this code in log4j.xml file:
<category name="org.hibernate">
<priority value="WARN" />
</category>
Its simple Just Add dependency to your pom.xml file
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
And it will disable logging and add put in src/main/resources/log4j.properties file
log4j.rootLogger=OFF
Then you can use it anytime if you want to display log on console then On it or else OFF
© 2022 - 2024 — McMap. All rights reserved.