Reality-Loop

QuickTip: Logging SQL statements in EclipseLink

September 07, 2011 | 0 Minute Read
This post was originally posted on my old blog.

1279316 question mark

Documentation for EclipseLink is quite lacking.

While for Hibernate it is quite easy to find out how to log SQL statements, I had some trouble to find out how to accomplish this in EclipseLink.

The solution are the following properties in persistence.xml:

 <property name="eclipselink.logging.level.sql" value="FINE"/>
 <property name="eclipselink.logging.parameters" value="true"/>

This solution I finally found here.

An alternative is also to use log4jdbc or log4jdbc-remix (the latter is available in the sonatype maven repository). An example is available in exercise 10 of my jpaworkshop.