Loading...

Show SQL statements in JBoss

Enable property in persistence.xml

<persistence -unit name="myPU">
    <jta-data-source>java:/oracledb</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"></property>
<property name="showSql" value="true"></property>
    </properties>
</persistence>

Set level debug in logback.xml or logback-test.xml.

<logger name="org.hibernate.SQL" level="DEBUG"></logger>

If you have another logging framework, you might adapt it there. Commands for the JBoss cli

/subsystem=logging/logger=org.hibernate.SQL:add
/subsystem=logging/logger=org.hibernate.SQL:write-attribute(name="level", value="DEBUG")
/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG")

Steps explained:

  • Add logger for subsystem logging
  • Set (write) log level for above logger
  • Set root log level to debug (not mandatory)