title: Control SQL logging level in Catalina.out
body: <p>Our app runs on Tomcat 8 and Linux. We have log4j.xml shipped with the war that controls the level of logging for our applications logging. The log4j also defines logging levels for SQL.</p>
  
  <p>In hibernate.cfg.xml, the "hibernate.show_sql" is set to true.</p>
  
  <pre><code>&lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
  </code></pre>
  
  <p>In $CATALINA_BASE/conf/logging.properties</p>
  
  <p>All references to ConsoleAppender:</p>
  
  <pre><code>log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  </code></pre>
  
  <p>Are removed, so nothing is sent to std out except for the SQL statements.</p>
  
  <p>The: "hibernate.show_sql">true, sends all SQL statements being processed to catalina.out – please note that catalina.out is a file created only on Linux/Unix machines.</p>
  
  <p>I read that "hibernate.show_sql">true, logs the SQL statements at DEBUG level. The problem is that I want to log those statements at ERROR level but don’t know how to control the level?</p>
  
  <p>I read that that level for SQL logging can be controlled by log4j.xml, but changing it in log4j.xml has no effect on how the catalina.out is being logged. Does anyone know how can I control the SQL logging in catalina.out to be only at ERROR level? </p>
  
  <p>Below is log4j.xml.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" &gt;
  &lt;log4j:configuration&gt;
  &lt;appender name="mylog" class="org.apache.log4j.RollingFileAppender"&gt;        
      &lt;param name="File" value="${catalina.base}/logs/mylog.log" /&gt;
      &lt;param name="Threshold" value="TRACE" /&gt;
      &lt;param name="Append" value="true" /&gt;
      &lt;param name="MaxFileSize" value="300MB" /&gt;
      &lt;param name="MaxBackupIndex" value="10" /&gt;
      &lt;layout class="it.openutils.log4j.FilteredPatternLayout"&gt;
          &lt;param name="ConversionPattern"
              value="%d{ISO8601} %5p [%t] Executor:%X{Executor} Type:%X{Type}     A:%X{Account} C:%X{Campaign} %c{1}:%L - %m%n" /&gt;            
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;logger name="org.hibernate.SQL" additivity="false"&gt;
      &lt;level value="ERROR" /&gt;
      &lt;appender-ref ref="mylog" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.hibernate"&gt;
          &lt;level value="ERROR"/&gt;
  &lt;/logger&gt;
  &lt;logger name="org.hibernate.jdbc.JDBCContext"&gt;
          &lt;level value="ERROR"/&gt;
  &lt;/logger&gt;
  
  &lt;root&gt;
      &lt;level value="info" /&gt;
      &lt;appender-ref ref="mylog" /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>