3 Replies Latest reply on Sep 29, 2011 7:27 AM by Are Tysnes

    JBoss 7 + Hibernate 4 + Log4j and application logging

    Are Tysnes Newbie

      To get access to the hibernate logging I have to do one of the following:


      1) If I only want the sql's (without parameters) the following properties in the persistence.xml of my application will do the trick:


      <property name="hibernate.show_sql" value="true"/>

      <property name="hibernate.format_sql" value="true"/>


      The output is located in the console and server.log


      2) If I want detailed (DEBUG) information from Hibernate I have to define a log category in the JBoss console:


      Name: org.hibernate

      Log Level: DEBUG


      I can add a handler to route this log to i.e. mylog.log (not possible to change the name of this file for some reason, but I can live with that)


      This is OK, but not good enough!


      I want to define the following in my log4j.properties in my application and route the hibernate logging wherever I want i.e.:







      log4j.appender.HIBERNATE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %40.40c.%-20.20M(%3.3L) %-6.6p:%m%n



      log4j.rootLogger=DEBUG, HIBERNATE




      This ha no effect and nothing is logged in hibernate.log coming from hibernate


      I also tried to include the following in the pom.xml:














      still no success...


      Anyone managed to get the hibernate logs controlled by your applications log4j ?