title: How to log SQL statement made by hibernate 4 in JBoss EAP 6.3
body: <p>I am currently developping a small webapplication wich i deploy on JBoss EAP 6.3.0.GA (version 7.4.0.Final-redhat-19).</p>
  
  <p>This application use hibernate as its JPA provider (hibernate version 4.2.14.SP1-redhat-1) and it also use an EJB between the webapp and the data layer).</p>
  
  <p>I have succesfully configured my application to log its processes through  log4j in a specific file.</p>
  
  <p>I have also succesfully configure hibernate to log the statement's parameters to the same file.</p>
  
  <p>THe log4j version used is 1.2.16.</p>
  
  <p>My problem is that the SQL statements generated by hibernate are never log to the file when i call my DAO through the webapp and those statements are logged to the server.log file if a remotely call to the business EJB through a main method.</p>
  
  <p>I need this logs because the log provided by the spy on the datasource is not suitable for my case (i must log the hibernate stuff on a application basis rather than for the whole server).</p>
  
  <p>Can you say me what i have misconfigured in my application ?
  Here is a link to github where my application is currently stored : <a href="https://github.com/lionelh/jboss-testing" rel="nofollow">https://github.com/lionelh/jboss-testing</a></p>
  
  <p>Thank you for your help.</p>
  
  <p>Here is also the log4j.properties wich is deployed with my application : </p>
  
  <pre><code>#
  # ROOT LOGGER
  #
  log4j.rootLogger=DEBUG
  
  log4j.appender.applog=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.applog.File=../standalone/log/jbosstesting.log
  log4j.appender.applog.DatePattern='-'yyyy-MM-dd
  log4j.appender.applog.layout=org.apache.log4j.PatternLayout
  log4j.appender.applog.layout.ConversionPattern=%5p *** %d{dd/MM/yyyy HH:mm:ss,SSS} *** (%C:%L) *** %m%n
  
  #
  # LOGGERS
  #
  log4j.logger.be.lionelh.jbosstesting=DEBUG, applog
  log4j.logger.org.hibernate.SQL=DEBUG, applog
  log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=trace, applog
  log4j.logger.org.hibernate.type.descriptor.sql.BasicEXtractor=trace, applog
  </code></pre>
  
  <p>Here is the content of the log file produced during JUnit test (this is what i want when the webapp is deployed) :</p>
  
  <pre><code>DEBUG *** 14/03/2015 16:30:36,996 *** [main] (UserDaoImpl.java:41) *** In findById
  DEBUG *** 14/03/2015 16:30:36,999 *** [main] (SqlStatementLogger.java:104)    *** select user0_.US_ID as US_ID1_0_0_, user0_.US_CREATION_DATE as US_CREAT2_0_0_, user0_.US_LANGUAGE as US_LANGU3_0_0_, user0_.US_LAST_UPDATE_DATE as US_LAST_4_0_0_, user0_.US_LOGIN as US_LOGIN5_0_0_ from phone_user user0_ where user0_.US_ID=?
  TRACE *** 14/03/2015 16:30:37,003 *** [main] (BasicBinder.java:84) *** binding parameter [1] as [BIGINT] - 1
  TRACE *** 14/03/2015 16:30:37,005 *** [main] (BasicExtractor.java:74) *** Found [2015-02-14 21:22:55.0] as column [US_CREAT2_0_0_]
  TRACE *** 14/03/2015 16:30:37,005 *** [main] (BasicExtractor.java:74) *** Found [F] as column [US_LANGU3_0_0_]
  TRACE *** 14/03/2015 16:30:37,006 *** [main] (BasicExtractor.java:74) *** Found [2015-02-14 21:22:55.0] as column [US_LAST_4_0_0_]
  TRACE *** 14/03/2015 16:30:37,006 *** [main] (BasicExtractor.java:74) *** Found [lh] as column [US_LOGIN5_0_0_]
  </code></pre>
  
  <p>Here is the content of the log when the application is deploy to JBoss (the SQL staement are missing :</p>
  
  <pre><code>DEBUG *** 14/03/2015 19:54:30,827 *** (be.lionelh.jbosstesting.web.UserBean:69) *** In login()
  DEBUG *** 14/03/2015 19:54:30,923 *** (be.lionelh.jbosstesting.data.ejb.JBossTestingBean:35) *** In createUser(UserDto)
  DEBUG *** 14/03/2015 19:54:30,924 *** (be.lionelh.jbosstesting.data.domain.dao.impl.UserDaoImpl:28) *** In create(User)
  TRACE *** 14/03/2015 19:54:31,146 *** (org.hibernate.type.descriptor.sql.BasicBinder:84) *** binding parameter [1] as [TIMESTAMP] - Sat Mar 14 19:54:31 CET 2015
  TRACE *** 14/03/2015 19:54:31,161 *** (org.hibernate.type.descriptor.sql.BasicBinder:84) *** binding parameter [2] as [VARCHAR] - F
  TRACE *** 14/03/2015 19:54:31,164 *** (org.hibernate.type.descriptor.sql.BasicBinder:84) *** binding parameter [3] as [TIMESTAMP] - Sat Mar 14 19:54:31 CET 2015
  TRACE *** 14/03/2015 19:54:31,165 *** (org.hibernate.type.descriptor.sql.BasicBinder:84) *** binding parameter [4] as [VARCHAR] - vp
  DEBUG *** 14/03/2015 19:54:31,286 *** (be.lionelh.jbosstesting.data.ejb.JBossTestingBean:42) *** In findAllUsers()
  DEBUG *** 14/03/2015 19:54:31,287 *** (be.lionelh.jbosstesting.data.domain.dao.impl.UserDaoImpl:35) *** In findAll()
  </code></pre>