javahibernatejpalog4jpersistence.xml

Hibernate Output in console is yet visible


i have a strange problem with hibernate. I want to avoid the output from hibernate, than i have changed my logback.xml and persistence.xml file, in order to make that.

persistence.xml

<properties>
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />
            <property name="hibernate.use_sql_comments" value="false" />
            <property name="hibernate.transaction.flush_before_completion" value="true" />
</properties>

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">

    <Pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{56}.%M (%file:%line\) =&gt; %msg%n</Pattern>
    </encoder>
  </appender>
   
  <logger name="org.hibernate" level="OFF"/>
  <logger name="org.hibernate.SQL" level="OFF"/>
  <logger name="org.hibernate.transaction" level="OFF"/>
  <logger name="org.hibernate.type" level="OFF"/>
  <logger name="org.hibernate.tool.hbm2ddl" level="OFF"/>
  <logger name="org.hibernate.pretty" level="OFF"/>
  <logger name="org.hibernate.cache" level="OFF"/>
  <logger name="org.hibernate.type.descriptor.sql" level="OFF" />

    
  <root level="OFF">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

but I get yet in the console a hibernate output and I want to avoid it.

Hibernate: select .....

i do not have any idea why, maybe can you help me?.


Solution

  • There could be more sources which are responsible for the hibernate output. Try the following steps to turn it off:

    1. Check log4j.logger.org.hibernate / log4j.logger.javax.persistence in your log4j config file and set it to error / none. (Optional if you got this file but try to find it).

    2. In your persistence.xml in tag set:

      hibernate.show_sql=false

      hibernate.format_sql=false

    I hope this will help you, keep your work up!