Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA 2.0 (logging and tracing through) with Glassfish 3.0.1 and NetBeans 6.9.1:

I am using JPA 2.0 (EclipseLink provider) with Glassfish v3.0.1 and NetBeans 6.9.1 and am NOT able to see the queries and other logging information from JPA 2.0. Essentially I want to be able to see all the SQL statements which are being generated by JPA and other related debugging information...

Has anyone successfully been able to configure the logging to provide such feedback? I've tried several things to no avail...

Any help would be greatly appreciated.

Thanks much.

like image 499
Alex H Avatar asked Jan 13 '11 04:01

Alex H


2 Answers

What eventually had done the trick for me was using:

<property name="eclipselink.logging.logger"
     value="org.eclipse.persistence.logging.DefaultSessionLog"/>
in conjunction with your recommended tag of:
<property name="eclipselink.logging.level" value="FINE" />
This allowed me to see the relevant JPA logs which in NetBeans output window. This also worked in Eclipse. The output was sent do the console window an intermingled with the server's output which was exactly what I wanted.
like image 194
Alex H Avatar answered Nov 12 '22 17:11

Alex H


You must configure logging level in persistence.xml file.

Example:

<persistence-unit name="MY_POOL_NAME" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>MY_JTA_SOURCE</jta-data-source>
    <properties>
        <property name="eclipselink.logging.level" value="FINE" />
        <property name="eclipselink.target-server" value="SunAS9"/>
    </properties>
  </persistence-unit>

Log Levels:
OFF
SEVERE
WARNING
INFO
CONFIG - Use this for Production
FINE
FINER
FINEST
More info: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging

All the queries would be printed in the domain server.log file.

like image 43
JSS Avatar answered Nov 12 '22 17:11

JSS