Loading...

Show SQL statements in JBoss

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

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)
Please remember the terms for blog comments.