2

I run localy wildfly 8.2 and have set the hibernate logging like this in standalone.xml

   <subsystem xmlns="urn:jboss:domain:logging:2.0">
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <formatter>
                <named-formatter name="COLOR-PATTERN"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE" autoflush="true">
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="org.jboss.as.config">
            <level name="DEBUG"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <logger category="org.hibernate">
            <level name="TRACE"/>
        </logger>
        <logger category="jboss.jdbc.spy">
            <level name="TRACE"/>

        </logger>
        <logger category="org.hibernate.type">
            <level name="TRACE"/>
        </logger>
        <logger category="org.hibernate.SQL">
            <level name="TRACE"/>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
        <formatter name="PATTERN">
            <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
        <formatter name="COLOR-PATTERN">
            <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
    </subsystem>

The persistence unit:

 <persistence-unit  name="cloudflow">
            <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
            <jta-data-source>java:jboss/datasources/cloudflow</jta-data-source>
            <properties>
             <!-- Properties for Hibernate -->
             <property name="hibernate.jdbc.batch_size" value="50"/>  
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />  
            </properties>
       </persistence-unit>

maven dependency :

    <dependency>
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
              <version>1.2.16</version>
              <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.3.2</version>
            </dependency>
 <!-- Import the JPA API, we use provided scope as the API is included in JBoss WildFly -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- JSR-303 (Bean Validation) Implementation -->
        <!-- Provides portable constraints such as @Email -->
        <!-- Hibernate Validator is shipped in JBoss WildFly -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
          <groupId>org.hibernate.common</groupId>
          <artifactId>hibernate-commons-annotations</artifactId>
          <version>4.0.4.Final</version>
          <scope>provided</scope>
        </dependency>

        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-core</artifactId>
          <version>4.3.0.Final</version>
          <scope>provided</scope>
        </dependency>

The sql queries are logged but not the binded parameters values...any clue why?

simonC
  • 4,101
  • 10
  • 50
  • 78
  • Is hibernate.show_sql turned on? Try to turn it off. – Dragan Bozanovic May 22 '15 at 14:45
  • If i turn it off I cann not see even the sql-s anymore so it doesn't help – simonC May 22 '15 at 15:42
  • It does help a lot, that's what I assumed. :) That means that your logging config is ignored entirely and sql was printed only because of hibernate.show_sql. Do you use Hibernate as a module from JBoss or you added it explicitly in your app (war, ear)? – Dragan Bozanovic May 22 '15 at 15:50
  • Also, is anything else logged at TRACE level from Hibernate? – Dragan Bozanovic May 22 '15 at 15:58
  • 1
    I wouldn't use logging and the `hibernate.show_sql` together. You're best to use one or the other. Have a look at the log categories http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch03.html#configuration-logging – James R. Perkins May 26 '15 at 21:35
  • if i remove hibernate.show_sql I dont see anything in the logs even the slq – simonC May 29 '15 at 10:00
  • @DraganBozanovic I'm using hibernate as a provided dependency via maven. – simonC Jul 09 '15 at 11:51
  • Then, try configuring it in your app's log4j.properties. – Dragan Bozanovic Jul 09 '15 at 12:26
  • @DraganBozanovic I have tried but with the same results ... no logs about hibernate visible. As i understand if I mark the dependency as providet it takes the hibernate module from jboss server so the logging should be configured ob server for hibernate – simonC Jul 09 '15 at 14:20
  • True, I did not understand you comment at first, I thought you _provide_ it as maven dependency. Does it take effect when you change `root-logger` level to `TRACE`? – Dragan Bozanovic Jul 09 '15 at 14:32
  • @Dragan Bozanovic, yes if I put root logger to trace I see everything but the log is quite heavy – simonC Jul 10 '15 at 15:09

1 Answers1

8

As I can see in your configuration, the output to the file log should be ok; it is only the console that cuts off everything below the INFO level.

To make this work in the console as well, delete the <level name="INFO"/> configuration in the console-handler.

Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110