I'm interested in logging SQL statements. I've tried two approaches, with log4j2 and writing to file, both in vain.
I've added following lines to persistence.xml
<property name="openjpa.Log" value="SQL=TRACE" />
<property name="openjpa.Log" value="File=openjpa_ra.log" />
<property name="openjpa.ConnectionFactoryProperties" value="PrintParameters=true" />
and I'm expecting it to write to the file, but nothing happened. On the other hand, when I specify
<property name="openjpa.Log" value="log4j" />
instead of file line, nothing is changes in my log4j2 files, despite having configured appender.
Update: I have configured the following in persistence.xml
:
<property name="openjpa.Log" value="File=d:\openra_log.log, DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
And now the file is produced, but lines I see there are only lines of
INFO [Worker-370] openjpa.Tool - Enhancer running on type "class type"
Anton , chances are the log4j configuration is overridden in one of a previously loaded component in the application server.
Your best bet to figure out what is happening could be to change the trace levels on the server side specifically for open JPA with the right trace level strings.
You can navigate to change logging detail (follow the crumb on the image)
and use a trace string for open JPA (*=info: openjpa.Query=all: openjpa.jdbc_JDBC=all: openjpa.jdbc_SQL=all). Changes in configuration will need a reboot of the server.