Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenJPA not logging when deployed on WAS 7

I have deployed my application to WebSphere Application Server 7, it uses the default OpenJPA 1.2.2 library in the application server, however, I cannot get it to log, I have this in my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
  xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="SvcsLogic" transaction-type="JTA">
   <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
   <jta-data-source>jdbc/mydatasource</jta-data-source>
   <exclude-unlisted-classes>true</exclude-unlisted-classes>
   <properties>
   <property name="openjpa.log" value="log4j, DefaultLevel=TRACE" />
   <property name="openjpa.Log" value="log4j, DefaultLevel=TRACE" />

   <property name="openjpa.jdbc.SynchronizeMappings"
      value="buildSchema(SchemaAction='add',foreignKeys=true)" />
   </properties>
</persistence-unit>
</persistence>

However, it will ignore the fact that I want it to log using log4j, even if I remove the log4j setting it won't modify the logging channels in WAS' Logs and Trace. I have it all set to log everything just to make sure, and it doesn't work.

The WAS Infocenter doc on JPA Logging says, however Avoid trouble: The “openjpa.Log” property will be ignored if it is defined in a container-managed persistence unit that uses the persistence providers that are provided with the application server. In this case you must use the standard trace specification for the application server.

Does this mean I have to change my JPA implementation just to get logging working? If so, this seems rather sloppy.

like image 418
Miguel Andrés Yáñez Avatar asked Dec 16 '22 20:12

Miguel Andrés Yáñez


1 Answers

In my opinion the only way to see what OpenJPA is doing behind the scenes in WebSphere v7 is to enable tracing in the admin console.

In order to activate OpenJPA tracing in the admin console, navigate to Troubleshooting - Logs and trace - [your server] - Diagnostic Trace. On the Configuration page, click on "Change Log Detail Levels" on the right side. Expand the components tree and select the OpenJPA log detail levels or enter

*=info: openjpa.Query=all: openjpa.jdbc_JDBC=all: openjpa.jdbc_SQL=all

into the text field. Click "OK" and then "save". You have to restart the server.

like image 129
mwalter Avatar answered Dec 22 '22 00:12

mwalter