1 Reply Latest reply on Jul 28, 2006 7:01 PM by Peter Royle

    Query Logging?

    Todd Main Newbie

      I don't know whether this is a question about Seam, EJB3, or JBoss/Hibernate...

      How do I control SQL logging? Ideally, I could systematically control whether any SQL is logged, as well as controlling specific types (SELECT/INSERT/UPDATE), or selected areas of the application (presumably package level).

      Also, I need to be able to change the setting while the application is running, in order to debug a production problem.

      I know how to do this when I'm using Log4j without an O/R framework, since I can wrap the PreparedStatement with my own version with a nice toString() method and some logging calls. I just don't know how to do this when I hand off the entire persistence job to the framework.

        • 1. Re: Query Logging?
          Peter Royle Newbie

          Hi ptmain,

          I'm not sure about the SELECT/INSERT/UPDATE or the package level stuff, but I think I've read in docs about how to turn full sql logging on and off. Mind you I've never actually tried it, so anyone with actual experience in this is welcome to correct me :)

          Anyway, since we're using hibernate and EJB I think you can set the following property in your persistence.xml (after jta-data-source):

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


          According to the Hibernate documentation regarding this property:

          This is an alternative to setting the log category org.hibernate.SQL to debug.


          Hope that works!

          Pete.