2

I know we can hide / show sql queries from hibernate.cfg.xml or persistence.xml with following code:

<property name="show_sql">true</property>

but is there any way to do same from jBoss configuration files?

Sagar Koshti
  • 408
  • 2
  • 6
  • 15
  • 1
    You should configure your own logger for it. If that is log4j, take a look: http://stackoverflow.com/a/436687/2102532 – meskobalazs Jan 16 '15 at 14:25

3 Answers3

7

in Jboss EAP 6.2.

Need to set environment variable by changing standalone.xml

<system-properties>
  <property name="org.jboss.as.logging.per-deployment" value="false"/>
</system-properties>

Alternately, you can give it as a JVM option.

$ standalone.sh -Dorg.jboss.as.logging.per-deployment=false

Then in standalone.xml add the following under <subsystem xmlns="urn:jboss:domain:logging:1.3"> element

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

Add these to hibernate.cfg.xml

<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
Poornan
  • 741
  • 2
  • 11
  • 25
1

There are two straightforward configuration that can be done on Wildfly/Jboss standalone.xml to display the queries along with placeholder values-

  1. Using Hibernate: enter image description here

  2. Using spy: enter image description here

then adding spy="true" property to the datasources you wish to get the queries logged for.

Caffeine Coder
  • 948
  • 14
  • 17
0

You can enable or disable logging of the following categories (using a log4j.properties file here):

log4j.properties

log4j.logger.org.hibernate=INFO, hb
log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE
log4j.logger.org.hibernate.hql.ast.AST=info
log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.hql=debug
log4j.logger.org.hibernate.cache=info
log4j.logger.org.hibernate.jdbc=debug

log4j.appender.hb=org.apache.log4j.ConsoleAppender
log4j.appender.hb.layout=org.apache.log4j.PatternLayout
log4j.appender.hb.layout.ConversionPattern=HibernateLog --> %d{HH:mm:ss} %-5p %c - %m%n
log4j.appender.hb.Threshold=TRACE

hibernate.cfg.xml

<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
CHHIBI AMOR
  • 1,186
  • 2
  • 13
  • 27