Chapter 3. Logging

3.1. Logging Channels
3.2. Disabling Logging
3.3. Log4J
3.4. JDK 1.4 java.util.logging
3.5. Simple Log
3.6. Custom Log

Logging is important for debugging and identifying performance hot spots in an application, as well as getting a sense of how Kodo operates. Using logging is essential for developing any persistent classes with custom object-relational mapping extensions, since observing the SQL that is generated will assist in quickly identifying any misconfigurations in the mapping information. Kodo provides a flexible logging system that integrates with many existing runtime systems, such as application servers and servlet runners.

Kodo JDO uses the Apache Jakarta Commons Logging thin library for issuing log messages. The Commons Logging libraries act as a wrapper around a number of popular logging APIs, including the Jakarta Log4J project, and the native java.util.logging package in JDK 1.4. If neither of these libraries are available, then logging will fall back to using simple console logging.

[Warning]Warning

Logging can have a negative impact on performance. Disable verbose logging (such as logging of SQL statements) before running any performance tests. It is advisable to limit or disable logging completely for a production system.

3.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 that are sent to the channel. Kodo uses the following logging channels:

  • kodo.Tool: Messages issued by the Kodo tools when run on the command line or via Ant. 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 as kodo.Enhance for the enhancer (see Section 5.4, “Enhancement”) or kodo.MetaData for the mapping tool (see Section 7.1, “Mapping Tool”). 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.

  • kodo.Enhance: Messages issued by the JDO enhancement process.

  • kodo.MetaData: Details about the parsing of JDO metadata and object-relational data.

  • kodo.Runtime: General Kodo runtime messages.

  • kodo.DataCache: Messages from the L2 data cache plugins.

  • kodo.jdbc.JDBC: JDBC connection information. General JDBC information will be logged to the TRACE level. Information about possible performance concerns will be logged to the INFO level.

  • kodo.jdbc.Schema: Details about operations on the database schema.

  • kodo.jdbc.SQL: This is the most common logging channel to use. Detailed information about the execution of SQL statements will be sent to the TRACE level. It is useful to enable this channel if you are curious about the exact SQL that Kodo issues to the data store.