title: How to disable hibernate sql logs in log4j2 with spring boot?
body: <p>We have an application written in spring boot. We are using Hibernate search 6 to fetch data from elasticsearch.
  We have configured log4j2 as below:</p>
  <p><strong>log4j2.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Configuration status=&quot;INFO&quot; packages=&quot;net.xxxx.logging&quot;&gt;
      &lt;Appenders&gt;
          &lt;Console name=&quot;Console&quot; target=&quot;SYSTEM_OUT&quot;&gt;
          &lt;/Console&gt;
          &lt;Console name=&quot;ConsoleDev&quot; target=&quot;SYSTEM_OUT&quot;&gt;
            &lt;PatternLayout pattern=&quot;%d{HH:mm:ss} [%t]
        %highlight{%level}{FATAL=bg_red, ERROR=red, WARN=yellow, INFO=green, DEBUG=blue} - %msg%n&quot;/&gt;
          &lt;/Console&gt;
        &lt;/Appenders&gt;
        &lt;Loggers&gt;
            &lt;Logger name=&quot;com.zaxxer.hikari&quot; level=&quot;${env:LOG_LEVEL_HIKARI:-INFO}&quot; additivity=&quot;false&quot; &gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Logger&gt;
            &lt;Logger name=&quot;org.hibernate&quot; level=&quot;INFO&quot; additivity=&quot;false&quot; &gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Logger&gt;
            &lt;Logger name=&quot;org.hibernate.search.fulltext_query&quot; level=&quot;INFO&quot; additivity=&quot;false&quot; &gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Logger&gt;
            &lt;Logger name=&quot;org.springframework&quot; level=&quot;${env:LOG_LEVEL_SPRING:-INFO}&quot; additivity=&quot;false&quot; &gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Logger&gt;
            &lt;Logger name=&quot;org.springframework.ldap&quot; level=&quot;${env:LOG_LEVEL_LDAP:-INFO}&quot; additivity=&quot;false&quot; &gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Logger&gt;
            &lt;Root level=&quot;INFO&quot; includeLocation=&quot;false&quot;&gt;
                &lt;AppenderRef ref=&quot;${env:LOG_CONSOLE:-Console}&quot; /&gt;
            &lt;/Root&gt;
        &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  <p><strong>application.yaml:</strong></p>
  <pre><code>spring:
    profiles: development
    liquibase.enabled: false
    jpa:
      show-sql: true
      properties:
        hibernate:
          format_sql: false
          dialect: org.hibernate.dialect.SQLServer2012Dialect
          generate_statistics: false
          search:
            enabled: true
            backend:
              type: elasticsearch
              dynamic_mapping: true
              uris: ${ELASTIC_SEARCH_URL}
              aws:
                region: us-west-2
                signing.enabled: true
  </code></pre>
  <p>We want to show hibernet sql queries logs show in debug mode only(in local environment) not in production build environment.</p>
  <p>We tried by setting <code>show_sql= false</code> in application.yaml file but it disable logs on local and prod both environment. We want to enable to log sql queries in local environment.</p>