title: Spring + Hibernate show_sql not working
body: <p>I'm trying to export the generated SQL query to the console using log4j. Spring 4 and Hibernate 4 are used.</p>
  
  <p>The servlet-context.xml:</p>
  
  <pre><code>    &lt;beans:bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;beans:property name="dataSource" ref="dataSource" /&gt;
      &lt;beans:property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
      &lt;beans:property name="hibernateProperties"&gt;
          &lt;beans:props&gt;
              &lt;beans:prop key="hibernate.show_sql"&gt;true&lt;/beans:prop&gt;
          &lt;/beans:props&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>the hibernate.cfg.xml </p>
  
  <pre><code>&lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;property name="dialect"&gt;
          org.hibernate.dialect.MySQLDialect
      &lt;/property&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;property name="connection.autocommit"&gt;false&lt;/property&gt;
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I call the following method, no infomation is generated at the console:</p>
  
  <pre><code>List&lt;Comment&gt; listComment = (List&lt;Comment&gt;) sessionFactory.getCurrentSession()
              .createCriteria(Comment.class).list();
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>==============================%================================</p>
  
  <p>I think the problem is in the log4j.xml file. BTW, I am using the Spring MVC project of STS. Spring 4.3.2 + Hibernate 4.2.5 + Tomcat 8.0 + log4j 1.2.15.</p>
  
  <p>log4j.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>
  </p>
  
  <pre><code>&lt;!-- Appenders --&gt;
  &lt;appender name="console" class="org.apache.log4j.ConsoleAppender"&gt;
      &lt;param name="Target" value="System.out" /&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%-5p: %c - %m%n" /&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;!-- Application Loggers --&gt;
  &lt;logger name="com.hersbitcloud.cancercloud"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;!-- 3rdparty Loggers --&gt;
  &lt;logger name="org.springframework.core"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.beans"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.context"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.springframework.web"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.hibernate"&gt;
      &lt;level value="info" /&gt;
  &lt;/logger&gt;
  
  &lt;logger name="org.hibernage.SQL"&gt;
      &lt;level value="debug" /&gt;
  &lt;/logger&gt;
  
  &lt;!-- Root Logger --&gt;
  &lt;root&gt;
      &lt;priority value="warn" /&gt;
      &lt;appender-ref ref="console" /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>
  
  <p>The log generated by Hibernate is:</p>
  
  <pre><code>INFO : org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
  INFO : org.hibernate.Version - HHH000412: Hibernate Core {4.3.5.Final}
  INFO : org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
  INFO : org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist
  INFO : org.hibernate.cfg.Configuration - HHH000044: Configuring from URL: file:/E:/OneDrive/PostDoc/SuperDr/Code/Spring/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/CancerCloud/WEB-INF/classes/hibernate.cfg.xml
  INFO : org.hibernate.cfg.Configuration - HHH000041: Configured SessionFactory: null
  INFO : org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
  INFO : org.hibernate.engine.transaction.internal.TransactionFactoryInitiator - HHH000399: Using default transaction strategy (direct JDBC transactions)
  INFO : org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory - HHH000397: Using ASTQueryTranslatorFactory
  INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 2663 ms
  </code></pre>
  
  <p>Even 'sessionFactory.getCurrentSession().createCriteria' does not generate any SQL statement.</p>
  
  <p>Is there anything I should add to the log4j.xml?</p>