How to enable JPA eclipselink logging in WAS Liberty

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. Read further to know about how to enable JPA eclipselink logging in WAS Liberty

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 two 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.

Please share it and help others if you found this blog helpful. Feedback, questions and comments are always welcome.

References:
https://www.ibm.com/support/knowledgecenter/en/SS7K4U_9.0.0/com.ibm.websphere.zseries.doc/ae/tejb_loggingwjpa.html

Further Reading

1 Comment

Comments