How to enable JPA eclipselink logging in WAS Liberty

Enable JPA eclipselink logging

When this goes well, you are happy but every developer hits situation when you need more logs and details to troubleshoot issue and determine root case. It happens many times when you work with JPA and thing don't goes as you expect. You really need to look under the hood what JPA is going, what SQL statements it's generating and executing.

Environment: WAS Liberty 17.0.01, JAVA EE 7, JPA 2.1, EclipseLink 2.6.3

In above environment, to enable JPA logging including SQL statements, bind parameters and transaction details do following -

Add following tow properties in persistence.xml
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.logging.parameters" value="true"/>

Add following logging tag in server.xml
<logging traceSpecification="eclipselink=all" maxFileSize="20" maxFiles="10"/>

Redeploy application and recycle server. All done!
This will enable JPA logging and you can see all log messages in server's trace.log file.

Comments

Other Popular Posts

Java Thread Local Storage explained in easiest practical way

EhCache3 as JCache (JSR-107) Implementation with Cache Statistics

Lambda Expression v/s Anonymous Inner Class - Java 8

EhCache3 In Memory Caching for Performance Improvement