title: How do I get more debug messages from Hibernate?
body: <p>I haven't been able to get any more console output (to help with debugging) from Hibernate despite setting a few properties in the <code>hibernate.cfg.xml</code> file. For example, adding the line <code>&lt;property name="show_sql"&gt;true&lt;/property&gt;</code> did not, in fact, show SQL statements in the console.</p>
  
  <p>I've also tried playing around with the contents of the <code>log4j.properties</code> file - like setting <code>log4j.logger.org.hibernate=debug</code> - with no luck. What am I missing?</p>
  
  <hr>
  
  <p><strong>Edit:</strong> the contents of the hibernate-service.xml file are</p>
  
  <pre><code>&lt;server&gt; 
      &lt;mbean code="org.jboss.hibernate.jmx.Hibernate" 
         name="jboss.har:service=Hibernate_SMS"&gt; 
          &lt;attribute name="DatasourceName"&gt;java:/SMS_DS&lt;/attribute&gt; 
          &lt;attribute name="Dialect"&gt;org.hibernate.dialect.HSQLDialect&lt;/attribute&gt; 
          &lt;attribute name="SessionFactoryName"&gt;java:/hibernate/SessionFactory&lt;/attribute&gt; 
          &lt;attribute name="CacheProviderClass"&gt;org.hibernate.cache.HashtableCacheProvider&lt;/attribute&gt;
          &lt;attribute name="ShowSqlEnabled"&gt;true&lt;/attribute&gt;
      &lt;/mbean&gt; 
  &lt;/server&gt;
  </code></pre>
  
  <p>I'm not 100% sure if this actually has any effect, though. That XML file is in the Eclipse project that handles my database stuff, but doesn't seem to be in the JBoss deploy directory.</p>
  
  <hr>
  
  <p><strong>Edit 2:</strong> This is definitely deployed as a HAR. That said, I'm pretty sure that I need <code>hibernate.cfg.xml</code> - I recall having problems when a mapping document was omitted as an entry in that file. I think the HAR is generated using ant - there's a target for it in the build.xml file:</p>
  
  <pre><code>&lt;target name="har" depends="prepare" description="Builds the Hibernate HAR file"&gt;
      &lt;mkdir dir="${class.root}" /&gt;
      &lt;mkdir dir="${distribution.dir}" /&gt;
  
      &lt;jar destfile="${distribution.dir}/${har.name}"&gt;                    
          &lt;!-- include the hbm.xml files  --&gt;
          &lt;fileset dir="${class.root}"&gt;
              &lt;include name="**/*.hbm.xml"/&gt;
              &lt;include name="com/[redacted]/sms/data/dto/*.class"/&gt;
              &lt;include name="com/[redacted]/sms/data/dto/base/*.class"/&gt;
          &lt;/fileset&gt;
  
          &lt;!-- include jboss-service.xml --&gt;
          &lt;metainf dir="${hibernate.dir}"&gt;
              &lt;include name="hibernate-service.xml"/&gt;
          &lt;/metainf&gt;
      &lt;/jar&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>but when I do the ant build with incorrectly-formed xml in the hibernate-service.xml file, it doesn't fail. <strong>Update</strong> Even deleting the file entirely doesn't cause a build to fail. Any ideas here? <strong>End Update</strong></p>
  
  <p>It sounds like getting Hibernate to output SQL statements should (if everything's set up correctly) take care of it entirely - does that mean that the settings in log4j.properties won't make a difference here? - because that actually <em>does</em> change the output when running ant.</p>
  
  <p><strong>Edit 3:</strong> After running into other weird issues with my data <code>har</code>, I deleted the har file entirely and rebuilt it using the <code>har</code> ant build target. Suddenly everything's working! Thanks to chessplay for his awesome helpfulness. Can't say I know exactly what did it in the end, but I'd rather acknowledge his efforts than write and accept my own answer; My apologies if you're not a "he."</p>