JPOX
JPOX
 JPOX Version 1.0
Configuration | Tutorials | Worked Examples | Developer
Obtaining JPOX
JPOX Preparation
JPOX Runtime
JPOX Logging

Java Persistent Objects JDO (JPOX) utilises the popular Log4J logging library. Moreover, JPOX logs messages to various categories, allowing you to filter the logged messages by these categories - so if you are only interested in a particular category you can effectively turn the others off.

Logging Categories

JPOX uses a series of categories, and logs all messages to these categories. Currently JPOX uses the following

  • JPOX.JDO - All messages general to JDO
  • JPOX.Cache - All messages relating to the JPOX Cache
  • JPOX.MetaData - All messages relating to MetaData
  • JPOX.General - All general operational messages
  • JPOX.Utility - All messages from JPOX utilities (e.g SchemaTool)
  • JPOX.Transaction - All messages relating to transactions
  • JPOX.RDBMS - All messages specific to the RDBMS persistence process
  • JPOX.RDBMS.DDL - All Data Definition Language messages
  • JPOX.RDBMS.SQL - All JDBC SQL messages (excluding DDL)
  • JPOX.RDBMS.Schema - All messages relating to the schema with the RDBMS persister
  • JPOX.OLAP - All messages specific to the OLAP persistence process.
  • JPOX.FileIO - All messages specific to the FileIO persistence process.
  • JPOX.Enhancer - All messages from the JPOX Enhancer.
  • JPOX.IDE - Messages from the JPOX IDE.

Logging levels

Log4J allows you to log messages at various severity levels. These are DEBUG, INFO, WARN, ERROR, FATAL. Each message is logged at a particular level to a category (as described above).

Enabling logging

To enable the JPOX log, you need to provide a Log4J configuration file when starting up your application. This may be done for you if you are running within a J2EE application server (check your manual for details). If you are starting your application yourself, you would set a JVM parameter as

-Dlog4j.configuration=file:log4j.lcf
                    
where log4j.lcf is the name of your Log4J configuration file.

The configuration file is very simple in nature, and you typically define where the log goes to (e.g to a file), and which logging level messages you want to see. Here's an example

log4j.rootCategory=, A1

# Define the log to be a file
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=jpox-test.log

# Appender A1 uses the PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{DATE} %-5p %c - %m%n

# Global Threshold - overridden by any Categories below.
#log4j.appender.A1.Threshold=INFO

# JPOX Categories
log4j.category.JPOX.JDO=INFO
log4j.category.JPOX.Cache=INFO
log4j.category.JPOX.MetaData=INFO
log4j.category.JPOX.General=INFO
log4j.category.JPOX.Utility=INFO
log4j.category.JPOX.Transaction=INFO

log4j.category.JPOX.RDBMS=DEBUG
log4j.category.JPOX.RDBMS.Schema=DEBUG
log4j.category.JPOX.RDBMS.DDL=DEBUG
log4j.category.JPOX.RDBMS.SQL=DEBUG

log4j.category.JPOX.OLAP=INFO

log4j.category.JPOX.FileIO=INFO

log4j.category.JPOX.Enhancer=INFO

log4j.category.JPOX.IDE=INFO
                

In this example, I am directing my log to a file (jpox-test.log). I have defined a particular "pattern" for the messages that appear in the log (to contain the date, level, category, and the message itself). In addition I have assigned a level "threshold" for each of the JPOX categories. So in this case I want to see all messages down to DEBUG level for the JPOX RDBMS persister.

Sample Log Output

Here is a sample of the type of information you may see in the JPOX log

21:26:09,000 INFO  JPOX.RDBMS - Adapter initialised : MySQLAdapter, MySQL version 4.0.11a-gamma'-Max' major 4 minor 0
21:26:09,365 INFO  JPOX.RDBMS - Creating table null.DELETE_ME1080077169045
21:26:09,370 DEBUG JPOX.RDBMS.DDL - CREATE TABLE DELETE_ME1080077169045
(
    UNUSED INTEGER NOT NULL
) TYPE=INNODB
21:26:09,375 DEBUG JPOX.RDBMS.DDL - Execution Time = 3 ms
21:26:09,388 WARN  JPOX.RDBMS.Schema - Schema Name could not be determined for this datastore
21:26:09,388 INFO  JPOX.RDBMS - Dropping table null.DELETE_ME1080077169045
21:26:09,388 DEBUG JPOX.RDBMS.DDL - DROP TABLE DELETE_ME1080077169045
21:26:09,392 DEBUG JPOX.RDBMS.DDL - Execution Time = 3 ms
21:26:09,392 INFO  JPOX.RDBMS.Schema - Initialising Schema "" using "SchemaTable" auto-start option
21:26:09,401 DEBUG JPOX.RDBMS - Retrieving type for table JPOX_TABLES
21:26:09,406 INFO  JPOX.RDBMS - Creating table null.JPOX_TABLES
21:26:09,406 DEBUG JPOX.RDBMS.DDL - CREATE TABLE JPOX_TABLES
(
    CLASS_NAME VARCHAR (128) NOT NULL UNIQUE ,
    `TABLE_NAME` VARCHAR (127) NOT NULL UNIQUE 
) TYPE=INNODB
21:26:09,416 DEBUG JPOX.RDBMS.DDL - Execution Time = 10 ms
21:26:09,417 DEBUG JPOX.RDBMS - Retrieving type for table JPOX_TABLES
21:26:09,418 DEBUG JPOX.RDBMS - Validating table : null.JPOX_TABLES
21:26:09,425 DEBUG JPOX.RDBMS - Execution Time = 7 ms
                

So you see the time of the log message, the level of the message (DEBUG, INFO, etc), the category (JPOX.RDBMS, etc), and the message itself. So, for example, if I had set the JPOX.RDBMS.DDL to DEBUG and all other categories to INFO I would see *all* DDL statements sent to the database and very little else.