Enabling Enhanced Tracing for JPA in a Java SE environment

In some cases it may be necessary to run a JPA trace from a JSE environment.

About this task

Enabling enhanced tracing for a Java SE environment

Enhanced trace can also be used gather additional JPA trace information in a JSE environment. In the WebSphere Application Server environment the application server takes care of coupling the standard OpenJPA trace with the enhanced trace function to produce a single trace output. This must be done manually in a JSE environment. Here are the steps to use enhanced tracing in a JSE environment:

Procedure

  1. Create a logging configuration properties file. This file must use the standard java.util.logging configuration file format. Below is a sample configuration file. The trace categories defined in the table below can also be used in the configuration file. As standard for java.util.logging configuration files, trace categories must be suffixed with .level.
    # Sample logger.properties file
    # Enable the file handler
    handlers = java.util.logging.FileHandler
    # Set a trace file pattern - this pattern will write a file named
    # jpa_jse.log into the current directory 
    java.util.logging.FileHandler.pattern = jpa_jse.log
    # Setup the basic logging level of the file handler
    java.util.logging.FileHandler.level = ALL
    # Set the standard OpenJPA jdbc.SQL category to trace level to ALL
    openjpa.jdbc.SQL.level = ALL
    # Set the enhanced OJPA_General category to trace at FINEST
    openjpa.OJPA_General.level = FINEST
    # Set the enhanced OJPA_Kernel category to trace at FINER
    openjpa.OJPA_Kernel.level = FINER
    
    Category Relevant trace levels Description
    JPA OFF, ALL, FINER, FINEST Adds extended trace to the JPA trace group.
    openjpa.* OFF, ALL, FINER, FINEST Normal OpenJPA trace in addition to extended trace for all catagories in OpenJPA when extended trace is enabled.
    openjpa.xtrace.* OFF, ALL, FINER, FINEST Extended trace for all categories in OpenJPA when extended trace is enabled.
    openjpa.xtrace.Jdbc OFF, ALL, FINER, FINEST Extended trace for OpenJPA JDBC classes when extended trace is enabled.
    openjpa.xtrace.Lib OFF, ALL, FINER, FINEST Extended trace for OpenJPA library classes when extended trace is enabled.
    openjpa.xtrace.Persist OFF, ALL, FINER, FINEST Extended trace for OpenJPA persistence classes when extended trace is enabled.
    openjpa.xtrace.Kernel OFF, ALL, FINER, FINEST Extended trace for OpenJPA kernel classes when extended trace is enabled.
    openjpa.xtrace.General OFF, ALL, FINER, FINEST Extended trace for OpenJPA classes not included in the Jdbc, Lib, Persist, or Kernel categories when extended trace is enabled.
  2. Modify your persistence.xml file to use Apache commons logging instead of the default OpenJPA logger. Add this property to your persistence unit:
    <property name="openjpa.Log" value="commons"/>
  3. Add the apache commons logging jar to your classpath. You can download the jar from the Apache Web site.
  4. Add the following argument to the JVM, where <WAS install path> is the fully qualified path of your application server install directory. Be sure to use the path separator character appropriate for your operating system. This parameter must be specified before the name of the class or jar to be executed.
    -javaagent:<WAS install path>/optionalLibraries/IBM/wsjpa/wsjpatrace.jar
  5. Add this additional argument to the JVM, specifying the path to your logging configuration file. This option must also be specified before the name of the class or jar to be executed.
    -Djava.util.Logging.config.file=Logger.properties
  6. Run your JSE application. Here is a sample JSE application invocation with enhanced trace enabled:
    java -javaagent:"C:\Program Files\IBM\WebSphere\AppServer\optionalLibraries\IBM\wsjpa\wsjpatrace.jar" -Djava.util.logging.config.file=logger.properties my.JPAApplication

Results

Enhanced tracing is now functioning in your Java SE environment.

What to do next

Note: Use of extended trace agent should not be used in combination with the OpenJPA PCEnhancer agent in a JSE environment. If enhanced tracing is used, the OpenJPA PCEnhancer must be used at compile time. If the enhancer and enhanced trace agents are used together the results are unpredictable.



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 2:56:59 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=tejb_jpatracejse
File name: tejb_jpatracejse.html