10

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.

Alex H
  • 421
  • 3
  • 13

2 Answers2

14

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.
Michael Paesold
  • 567
  • 4
  • 12
Alex H
  • 421
  • 3
  • 13
  • 1
    Is it possible to differentiate productive system and development system automatically. Setting the level to INFO every time bevor you deploy it to live system is too much work and also dangerous if you forget. – Hasan Tuncay Mar 28 '13 at 10:25
5

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.

JSS
  • 1,805
  • 1
  • 17
  • 23
  • 4
    Thanks for your answer. What eventually had done the trick for me was using: in conjunction with your recommended tag of: . 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. – Alex H Feb 26 '11 at 20:13