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

2

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.

Mesoglea answered 13/1, 2011 at 4:14 Comment(0)
M
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.
Mesoglea answered 26/2, 2011 at 20:18 Comment(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.Palatable
M
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.

Mathew answered 16/1, 2011 at 13:22 Comment(1)
Thanks for your answer. 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.Mesoglea

© 2022 - 2024 — McMap. All rights reserved.