Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to output generated SQL using EclipseLink without having to increase log verbosity?

I want to output the SQL generated by EclipseLink to the console, during development. However, I could only do so using the logging level FINE. I have a complex domain model composed of many classes, so much that deployment takes a considerable ammount of time when the log verbosity is on the FINE level, since EclipseLink outputs its analysis of the whole model.

Is there a way to get the SQL without resorting to log level FINE (like Hibernate does)?

like image 593
javabeats Avatar asked Mar 03 '10 19:03

javabeats


2 Answers

Put the following properties in your persistence.xml:

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

The latter is helpful, so that the values of the parameter are shown.

An alternative is using log4jdbc or log4jdbc-remix.

like image 124
jbandi Avatar answered Sep 17 '22 19:09

jbandi


The log generation for EclipseLink seems quite difficult to set, according to this thread.

It mentions a persistence.xml file with log level you can adapt:

<property name="eclipselink.weaving" value="static" /> <property name="eclipselink.logging.level.sql" value="FINEST" /> <property name="eclipselink.logging.level" value="FINEST" /> <property name="eclipselink.logging.level.cache" value="FINEST" /> 

But some other settings may be needed.

As Martin documents below, "EclipseLink/Examples/JPA/Logging" documents those properties.

like image 37
VonC Avatar answered Sep 18 '22 19:09

VonC