Chapter 3. Logging
Prev | Part V. Kodo JDO Reference Guide | Next

## Chapter 3. Logging

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 can 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.

There are four built-in log plugins: a simple logging framework that covers basic needs, a Log4J delegate, an Apache Commons Logging delegate, and a no-op implementation for disabling logging.

| 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. You can disable logging altogether by setting the `kodo.Log` property to `none`.

## 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.5, “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.Configuration`: Messages issued by the configuration framework.

- `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.Query`: Messages about queries issued via the JDO query facilities. Queries and any parameter values, if applicable, will be logged to the `TRACE` level at execution time. Information about possible performance concerns will be logged to the `INFO` level.

- `kodo.Remote`: Remote connection and execution 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.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.

  When using the built-in Kodo logging facilities, you can enable this by adding `SQL=TRACE` to your `kodo.Log` property:

      kodo.Log: SQL=TRACE

  Kodo can optionally reformat the logged SQL to make it easier to read. To enable pretty-printing, add `PrettyPrint=true` to the `kodo.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 it harder to process with tools like grep.

  Pretty-printing properties configuration might look like so:

      kodo.ConnectionFactoryProperties: MaxActive=100, PrettyPrint=true, PrettyPrintLineLength=72

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

- `com.solarmetric.Manage`: JMX and management-related logging channel.

- `com.solarmetric.Profile`: Information related to Kodo's profiling framework.

Prev | Up | Next
2.6. Kodo JDO Properties | Home | 3.2. Kodo Logging