3.4.1. Logging Channels
Logging is done over a number of logging channels, each of which has a logging level which controls the verbosity of log messages recorded for the channel. OpenJPA uses the following logging channels:
-
openjpa.Tool: Messages issued by the OpenJPA command line and Ant tools. Most messages are basic statements detailing which classes or files the tools are running on. Detailed output is only available via the logging category the tool belongs to, such asopenjpa.Enhancefor the enhancer (see Enhancement) oropenjpa.MetaDatafor the mapping tool (see Forward Mapping). This logging category is provided so that you can get a general idea of what a tool is doing without having to manipulate logging settings that might also affect runtime behavior. -
openjpa.Enhance: Messages pertaining to enhancement and runtime class generation. -
openjpa.MetaData: Details about the generation of metadata and object-relational mappings. -
openjpa.Runtime: General OpenJPA runtime messages. -
openjpa.Query: Messages about queries. Query strings and any parameter values, if applicable, will be logged to theTRACElevel at execution time. Information about possible performance concerns will be logged to theINFOlevel. -
openjpa.DataCache: Messages from the L2 data cache plugins. -
openjpa.jdbc.JDBC: JDBC connection information. General JDBC information will be logged to theTRACElevel. Information about possible performance concerns will be logged to theINFOlevel. -
openjpa.jdbc.SQL: This is the most common logging channel to use. Detailed information about the execution of SQL statements will be sent to theTRACElevel. It is useful to enable this channel if you are curious about the exact SQL that OpenJPA issues to the datastore.
|
|
The SQL issued to the database may contain sensitive information. By default the
parameter values used in the prepared statements generated by OpenJPA will not
be printed in the SQL log - instead you will see a ? for each value. The actual
values may be printed by adding PrintParameters=True |
When using the built-in OpenJPA logging facilities, you can enable SQL logging by adding SQL=TRACE to your openjpa.Log property.
OpenJPA can optionally reformat the logged SQL to make it easier to read.
To enable pretty-printing, add PrettyPrint=true to the openjpa.ConnectionFactoryProperties property.
You can control how many columns wide the pretty-printed SQL will be with the PrettyPrintLineLength property.
The default line length is 60 columns.
While pretty printing makes things easier to read, it can make output harder to process with tools like grep.
Pretty-printing properties configuration might look like so:
<property name="openjpa.Log" value="SQL=TRACE"/>
<property name="openjpa.ConnectionFactoryProperties"
value="PrettyPrint=true, PrettyPrintLineLength=72"/>
-
openjpa.jdbc.SQLDiag: This logging channel provides additional information about entity actitvies such as create, find, update or delete, and eager loading of relation or field properties. If you enable this channel, it is recommended thatopenjpa.jdbc.SQLchannel is also enabled. The additional trace can help you relate the entity activities to the execution of SQL statements that OpenJPA issued to the datastore.
When using the built-in OpenJPA logging facilities, you can enable SQLDiag logging by adding SQLDiag=TRACE to your openjpa.Log property.
-
openjpa.jdbc.Schema: Details about operations on the database schema.